Last active
September 7, 2015 01:55
-
-
Save chaddotson/5199c2da38d34335041a to your computer and use it in GitHub Desktop.
Copy and paste in the console of a page without jquery to load jquery. Leaves no artifacts of itself once it executes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// loading jQuery on a site that doesn't have jquery for fun and ... hmmm profit?. | |
(function (jQueryURL) { | |
function loadSuccess() { | |
eval(this.responseText); | |
console.log("jQuery loaded."); | |
} | |
function loadFailed(event) { | |
console.log("Failed to load jQuery source.", event); | |
} | |
if(window.jQuery) { | |
console.log("jQuery " + $.fn.jquery + " already loaded."); | |
return; | |
} | |
var request = new XMLHttpRequest(); | |
request.addEventListener("load", loadSuccess, false); | |
request.addEventListener("error", loadFailed, false); | |
request.open("GET", jQueryURL, true); | |
request.send(); | |
})("https://code.jquery.com/jquery-2.1.4.js"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment