Skip to content

Instantly share code, notes, and snippets.

@dschep
Last active December 17, 2015 03:59
Show Gist options
  • Save dschep/5547713 to your computer and use it in GitHub Desktop.
Save dschep/5547713 to your computer and use it in GitHub Desktop.
fartscroll.js
javascript:(function(){function b(b,e){var c=document.getElementsByTagName("head")[0],a=document.createElement("script");a.src=b;var d=!1;a.onload=a.onreadystatechange=function(){if(!d&&(!this.readyState||"loaded"==this.readyState||"complete"==this.readyState))d=!0,e(),a.onload=a.onreadystatechange=null,c.removeChild(a)};c.appendChild(a)}void 0===window.jQuery?b("https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js",function(){$("<script>").attr("type","text/javascript").text("$.noConflict();").appendTo("body");
b("https://raw.github.com/theonion/fartscroll.js/master/fartscroll.js",function(){jQuery(document).fartscroll()})}):b("https://raw.github.com/theonion/fartscroll.js/master/fartscroll.js",function(){jQuery(document).fartscroll()})})();
(function() {
// from http://stackoverflow.com/questions/756382/bookmarklet-wait-until-javascript-is-loaded
function loadScript(url, callback)
{
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = url;
// Attach handlers for all browsers
var done = false;
script.onload = script.onreadystatechange = function()
{
if( !done && ( !this.readyState
|| this.readyState == "loaded"
|| this.readyState == "complete") )
{
done = true;
// Continue your code
callback();
// Handle memory leak in IE
script.onload = script.onreadystatechange = null;
head.removeChild( script );
}
};
head.appendChild(script);
}
if (window.jQuery === undefined) {
loadScript('https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', function() {
$('<script>').attr('type', 'text/javascript').text('$.noConflict();').appendTo('body');
loadScript('https://raw.github.com/theonion/fartscroll.js/master/fartscroll.js', function() {
jQuery(document).fartscroll();
});
});
} else {
loadScript('https://raw.github.com/theonion/fartscroll.js/master/fartscroll.js', function() {
jQuery(document).fartscroll();
});
}
})();
@dschep
Copy link
Author

dschep commented May 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment