How to load jQuery anywhere
Published 2013-2-11Watch on YouTube: youtu.be/F73hHZki4_c
Check out How to create a bookmarklet if you're interested in learning more about bookmarklets.
[jquerify]: javascript:(function()%7B%22use%20strict%22;function%20t()%7Bconsole.log(%22jQuery%20loaded!%22)%7Dvar%20e;e=document.createElement(%22script%22);e.addEventListener(%22load%22,t);e.src=%22//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js%22;document.head.appendChild(e)%7D())
If you drag this bookmarklet to your bookmarks bar and click on it on any page (with some exceptions), it will load jQuery.
[jQuerify][jquerify]
- Use Google Chrome
- Click on the menu button in the upper-right-hand corner (looks like 3 vertical bars stacked on top of eachother)
- Move your mouse over Bookmarks
- Select Show Bookmarks Bar if it isn't already selected
- Click and drag the jQuerify link (above) to the Bookmarks Bar
- On any page, click the link and jQuery will load
Exceptions: There's a new Content Security Policy (CSP) that can prevent loading external scripts through the use of a bookmarklet. Facebook, for example, uses this.
Note to experts:
And here's the (unminified) source, if you were curious:
(function () {
"use strict";
var js
;
function confirmSuccess() {
console.log("jQuery loaded!");
}
js = document.createElement("script");
js.addEventListener("load", confirmSuccess);
js.src = "//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.js";
document.head.appendChild(js);
}());
By AJ ONeal
Did I make your day?
Buy me a coffee
(you can learn about the bigger picture I'm working towards on my patreon page )