Skip to content

Instantly share code, notes, and snippets.

@yoko
Created March 26, 2010 22:23
Show Gist options
  • Save yoko/345478 to your computer and use it in GitHub Desktop.
Save yoko/345478 to your computer and use it in GitHub Desktop.
var greasemonkey = (typeof unsafeWindow != 'undefined');
if (greasemonkey)
Foo.setup(); // use @resource
else {
// referred to jQuery
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js';
var done = false;
script.onload = function() {
if (done) return;
done = true;
Foo.setup();
};
head.insertBefore(script, head.firstChild);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment