Skip to content

Instantly share code, notes, and snippets.

@fabriceleal
Last active December 17, 2015 03:59
Show Gist options
  • Save fabriceleal/5547487 to your computer and use it in GitHub Desktop.
Save fabriceleal/5547487 to your computer and use it in GitHub Desktop.
Bookmarklet to import fartscroll.js (imports jquery 1.9.1 if cant find jQuery).
(function(){
var a = function(){
var y = document.createElement('script');
y.onload = function(){ jQuery(document).fartscroll(600) };
y.src="https://raw.github.com/theonion/fartscroll.js/master/fartscroll.js";
document.head.appendChild(y);
};
if(typeof jQuery == 'undefined') {
var x = document.createElement('script');
x.onload = a;
x.src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";
document.head.appendChild(x);
} else {
a();
}
})();
/*
Minified:
(function(){var e=function(){var e=document.createElement("script");e.onload=function(){jQuery(document).fartscroll(600)};e.src="https://raw.github.com/theonion/fartscroll.js/master/fartscroll.js";document.head.appendChild(e)};if(typeof jQuery=="undefined"){var t=document.createElement("script");t.onload=e;t.src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js";document.head.appendChild(t)}else{e()}})()
*/
@fabriceleal
Copy link
Author

Fixed to import jQuery when needed

@fabriceleal
Copy link
Author

Weird behavior using $. Switch to jQuery

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