Skip to content

Instantly share code, notes, and snippets.

@sooop
Created February 13, 2013 15:03
Show Gist options
  • Save sooop/4945207 to your computer and use it in GitHub Desktop.
Save sooop/4945207 to your computer and use it in GitHub Desktop.
enable jQuery - the bookmarklet
javascript:
(function(){
var v = '1.9.1';
if (window.jQuery == undefined || window.jQuery.fn.jquery <; v) {
var done = false;
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/"+v+"/jquery.min.js";
document.getElementsByTagName("head")[0].appendChild(script);
script.onload = script.onreadystatechange =
function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState === "complete" )) {
done = true;
console.log('jQuery '+v+' is loaded successfully.');
initMyBookmarklet();
}
};
} else {
/* if the latest version of jQuery is loaded, call the callback. */
initMyBookmarklet();
}
function initMyBookmarklet() {
(window.mybookmarklet = function() {
var uiv = '1.8.2';
if(!$){
console.log('no $! set $ to jQuery');
$ = jQuery;
}
if(!$.ui || $.ui.version <; uiv)
{ /* include jQuery UI */
var uiscript = $('<;script/>;');
uiscript.attr('src',"http://ajax.googleapis.com/ajax/libs/jqueryui/"+uiv+"/jquery-ui.min.js");
uiscript.load(function(e){ console.log('jquery ui is loaded:'+uiv); });
$('head')[0].appendChild(uiscript[0]);
}
console.log('done');
})();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment