gitmyhub

history.js

JavaScript ★ 11k updated 4y ago

History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.

An archived JavaScript library from 2013 that normalized browser differences in the HTML5 History API and added hash-based fallbacks for old browsers, now obsolete, as modern browsers have converged on the native standard.

JavaScriptjQueryMooToolsPrototypesetup: easycomplexity 2/5

History.js is a JavaScript library that smooths out inconsistencies in how browsers handle the HTML5 History API, and adds a backwards-compatible fallback for older browsers that do not support it. The HTML5 History API lets web pages change the URL in the browser's address bar and manage navigation history without reloading the page, which is how many modern single-page web apps work. The problem is that different browsers have implemented this API slightly differently over the years, producing subtle bugs and inconsistencies. History.js aimed to normalize those differences.

For browsers that do not support the HTML5 History API at all, History.js falls back to using URL hashes, the fragment that appears after a # sign in an address. This allowed sites built with History.js to work across a wide range of browsers, including much older ones, while still behaving correctly in modern ones. The library offered adapters for popular JavaScript frameworks of its era including jQuery, MooTools, and Prototype.

The practical use case was websites that wanted to load content without full page refreshes, often called Ajax navigation or Ajaxify. History.js provided a consistent way to update the address bar as the user navigated, so that the back button worked correctly and pages were bookmarkable even though the content was loaded dynamically.

The README is candid about the project's current state. The last release was in 2013. The maintainer explains that testing requires running manual checks across many browser and adapter combinations, which is time-consuming work that was never funded. The note advises that modern browsers have converged enough on the native API that a polyfill library is no longer needed for current projects. The repo now exists mainly as an archive for anyone still supporting very old browsers. No active maintenance is planned.

Where it fits