Skip to content

Instantly share code, notes, and snippets.

@filipkral
Last active August 29, 2015 14:04
Show Gist options
  • Save filipkral/c4b907c216eb0b4619fa to your computer and use it in GitHub Desktop.
Save filipkral/c4b907c216eb0b4619fa to your computer and use it in GitHub Desktop.
Function to load jQuery in a browser console or alike.
// self-executing oneliner to paste it to console
(function load_jQuery(){var jq = document.createElement('script'); jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; document.getElementsByTagName('head')[0].appendChild(jq); setTimeout(function(){ jQuery.noConflict(); console.log('jQuery should be available as jQuery now.'); }, 3000); })();
// the above function in readable form
function load_jQuery(){
// Load jQuery
// based on http://stackoverflow.com/questions/7474354/include-jquery-in-the-javascript-console
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type.
setTimeout(function(){
jQuery.noConflict();
console.log('jQuery should be available as jQuery now.');
}, 3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment