Skip to content

Instantly share code, notes, and snippets.

@23maverick23
Last active May 19, 2021 08:48
Show Gist options
  • Save 23maverick23/4243305 to your computer and use it in GitHub Desktop.
Save 23maverick23/4243305 to your computer and use it in GitHub Desktop.
JavaScript: Bookmarklet with jQuery
(function(){
// the minimum version of jQuery we want
var v = "1.8.3";
// check prior inclusion and version
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";
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
initMyBookmarklet();
}
};
document.getElementsByTagName("head")[0].appendChild(script);
} else {
initMyBookmarklet();
}
function initMyBookmarklet() {
(window.myBookmarklet = function() {
// your JavaScript code goes here!
})();
}
})();
@jmtdev0
Copy link

jmtdev0 commented Apr 28, 2020

(04/28/2020)
script.src = "https..." 🙂

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