public
Last active

History.js It! A bookmark for trialing History.js on your own website.

  • Download Gist
bookmark-helper.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
(function(window,undefined){
// Load Helpers
var
intervalScript, intervalJquery,
loadScript = function(scriptUrl){
var e = document.createElement('script');
e.setAttribute('src',scriptUrl);
window.document.body.appendChild(e);
return e;
};
// Load In Basic Dependencies
if ( typeof window.jQuery === 'undefined' || /^1\.[0-3]/.test(window.jQuery.fn.jquery) ) {
loadScript('https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js');
}
 
// Load In Advanced Dependencies
intervalJquery = setInterval(function(){
if ( typeof window.jQuery !== 'undefined' ) {
clearInterval(intervalJquery);
loadScript('http://balupton.github.com/history.js/scripts/bundled/html4+html5/jquery.history.js');
loadScript('https://raw.github.com/balupton/jquery-scrollto/master/scripts/jquery.scrollto.min.js');
}
},500);
// Load In Script
intervalScript = setInterval(function(){
if ( typeof window.jQuery !== 'undefined' && typeof window.History !== 'undefined' && typeof window.History.initHtml4 !== 'undefined' ) {
if ( window.console ) {
window.console.log('Loading in script');
}
$(loadScript('https://raw.github.com/gist/854622/ajaxify-html5.js')).bind('load',function(){
if ( typeof window.historyjsitNoAlert === 'undefined' ) {
alert('History.js It! Is ready for action!');
}
});
clearInterval(intervalScript);
}
else if ( window.console ) {
window.console.log('Waiting for dependencies to load');
}
},500);
})(window);
readme.md
Markdown

This gist has moved! Click here for the new location

ScreenCast

See it in action here: http://vimeo.com/22396598

Usage

  1. Click the raw link for the bookmark.js file, and copy the contents into your clipboard: ctrl+a, ctrl+c for windows or cmd+a, cmd+c for mac
  2. Right click your browsers bookmark bar and select add new page, for the title use History.js It! for the url press ctrl+v for windows or cmd+v for mac

Notes

It loads in all History.js dependencies and History.js if it needs to, then it loads in the gist https://gist.github.com/854622 - if it doesn't work, evaluate that gist

Todo

  1. Support forms
  2. Support sub-pages

Suggest using Github Pages for scripts/resources (not /raw/).

It breaks the HTML5 boilerplate jQuery fallback:

<script>
window.jQuery || document.write('<script src="/js/jquery.js"><\/script>')
</script>

Example:
http://guidobouman.com/dev/blog/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.