Skip to content

Instantly share code, notes, and snippets.

@thanhpk
Last active April 28, 2017 13:34
Show Gist options
  • Save thanhpk/39f2b80de5989122a8a6f2060488b7eb to your computer and use it in GitHub Desktop.
Save thanhpk/39f2b80de5989122a8a6f2060488b7eb to your computer and use it in GitHub Desktop.
Add JQuery programatically to a page use Google Console
function addJquery(cb) {
if (typeof(jQuery) !== 'undefined') return;
var url = 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js';
var scr = document.createElement('script'); scr.setAttribute('type', 'text/javascript'); scr.setAttribute('src', url);
var head = document.getElementsByTagName('head')[0]; head.insertBefore(scr, head.firstChild);
}
addJquery();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment