Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
@mintyPT

This comment has been minimized.

Copy link

mintyPT commented Jan 21, 2015

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

@JuanjoFR

This comment has been minimized.

Copy link

JuanjoFR commented Nov 7, 2015

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

This comment has been minimized.

Copy link

ghprod commented Dec 10, 2015

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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
You can’t perform that action at this time.