balupton/history.js — Issue #148: HTML4 to HTML5 URL Transformation
Author: jasonhill
Created: 2012-01-15 23:16:36+00:00
State: open

For HTML5 browsers with querystring values, we are able to load the correct state into the initial page load from server side code as we have access to the state in the querystring. This means the correct content is visible on the page to search engines crawling the site whereas if we loaded the state via ajax, then search engines wouldn't see the correct content as they wouldn't be executing the javascript code.

Now, if we take a URL from an HTML4 browser with hashed state parameters and paste that into an HTML 5 browser, the URL is transformed into the HTML5 equivalent using querystring parameters instead of hash values. This seems to happen before we have had a chance to bind the statechange event so we are unaware of the change and there doesn't seem to be any other event being fired that would allow us to detect this auto-transform.

This means the correct page state isn't getting loaded as the initial querystring values aren't sent to the server because replaceState is being called. We don't want to always load the state again via ajax on the initial page load because normally, with HTML5 browsers, the page would have the correct state from server side code.

It would be good to have a way to control this auto-transform feature on the initial page load, possibly delaying it until after we have bound the statechange event.