HTML5 History APIs for legacy browsers. Implements window.history.pushState(), window.history.replaceState(), and the window.onpopstate event.
Failed to load latest commit information.
bin/closure-compiler Initial Version. Supports IE8, FF3.6, Chrome, and Safari Jul 22, 2010
src Redirect on load of a generated hash is detected Aug 10, 2010
test Link test up to DEBUG version by default Aug 10, 2010
Rakefile Auto-generate gzipped version when compiling Aug 10, 2010


history.js provides an implementation of the HTML5 history API: history.pushState and history.replaceState functions, as well as the window.onpopstate event.

Browsers that already support his event (Chrome & Safari, Firefox 4+) use native implementations, which are able to change the page URL without refreshing the page. Older browsers use location.hash in order to mimic the official behavior.

1214 bytes minified / 588 bytes gzipped


  • Does not support multiple handlers for the onpopstate event


Include the script file in your HTML file:

<!-- Include JSON if you want to support older browsers -->
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript" src="history-min.js"></script>


Same as the official HTML5 API:

// Switch to the item
window.history.pushState({ id: 35 }, 'Viewing item #35', '/item/35'});

window.onpopstate = function (e) {
  var id =;

Any use allowed in the standard but not supported by this API is considered a bug.

Supported & Tested Browsers

  • Chrome 5+ & Safari 5+ (Native)
  • Firefox 4+ (Native)
  • Firefox 3.5+
  • Chrome 4+
  • Safari 4+
  • IE8+

Unsupported / Need to test

  • Opera ?
  • IE6-7
  • Safari 3+ (No persitence)
  • Chrome 3+ (No persitence)
  • Firefox 2+ (No persitence)


  • Support IE6&7
    • Use iframe for history
    • Use userData behavior for persistence
  • Support FF2+
    • Use globalStorage for persistence
  • Chrome < 4
    • Use Gears?
  • Fallback for browsers that are unsupported