Skip to content

Instantly share code, notes, and snippets.

@zxcvbnm4709
Created May 10, 2012 22:06
Show Gist options
  • Save zxcvbnm4709/2656197 to your computer and use it in GitHub Desktop.
Save zxcvbnm4709/2656197 to your computer and use it in GitHub Desktop.
include jQuery in Chrome Console
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);
@kherge
Copy link

kherge commented Oct 11, 2016

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);

@TarasMazepa
Copy link

TarasMazepa commented Jan 16, 2018

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);

@imjosh
Copy link

imjosh commented Jan 6, 2019

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