Created
May 10, 2012 22:06
-
-
Save zxcvbnm4709/2656197 to your computer and use it in GitHub Desktop.
include jQuery in Chrome Console
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
var script = document.createElement("script"); | |
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"); | |
script.addEventListener('load', function() { | |
var script = document.createElement("script"); | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); |
It's better if you remove the "http:" part (to load on https too):
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
Update to latest jquery
var script = document.createElement("script");
script.setAttribute("src", "//code.jquery.com/jquery-1.11.3.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
Always use the latest:
var script = document.createElement("script");
script.setAttribute("src", "//code.jquery.com/jquery-latest.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
Always use let ;)
let script = document.createElement("script");
script.setAttribute('src', '//code.jquery.com/jquery-latest.min.js');
script.addEventListener('load', function() {
let script = document.createElement('script');
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
I couldn't get this to work with what I was doing. This one worked for me and it uses promises:
fetch('https://code.jquery.com/jquery-latest.min.js')
.then(r => r.text())
.then(r => { Function(`'use strict'; ${r}`)() });
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. I used it to build a bookmarklet
javascript:var script = document.createElement("script"); script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"); script.addEventListener('load', function() {var script = document.createElement("script"); document.body.appendChild(script); }, false); document.body.appendChild(script);