browserstate / history.js

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.
http://browserstate.github.com/history.js/demo/
Other
10.74k stars 1.35k forks source link

History.js and its plugins crash when combined into a single JavaScript file. #83

Closed garyv closed 13 years ago

garyv commented 13 years ago

On websites that combine multiple JavaScript files into one, history.js crashes with "undefined method" errors.

I consider this a bug because:

Details:

Quick and dirty fix:

Add a millisecond delay to each script file after the first one.

// contents of history.adapter.jquery.js
setTimeout(function(){
    // contents of history.js
}, 1);
setTimeout(function(){
    // contents of history.html4.js
}, 1);

This is clearly too hacky to be a permanent fix, but it illustrates the problem well: History.js is dependent on the delay normally caused by loading each script with a separate HTTP request.

JasonBerry commented 13 years ago

I'm pretty sure this is a duplicate of https://github.com/balupton/history.js/issues/46

garyv commented 13 years ago

Thanks Jason, not sure how I missed that other ticket.

I re-minified the files using Google Closure Compressor and YUI Compressor, and each one let me combine the files without causing a glitch.

My question now is, what compressor was used on the minified files in this repo, and why not switch it to YUI or Closure? But I suppose I should just create a pull request for that.

JasonBerry commented 13 years ago

UglifyJS is used to do the minification. There's a feature request ticket to not omit the trailing semicolons, but it hasn't been actioned as yet.

balupton commented 13 years ago

Fixed in v1.7.1. We now also include bundled files in the distro :) Thanks guys.

Angelinsky7 commented 7 years ago

Still not working in 2017...