Skip to content

Instantly share code, notes, and snippets.

@sinky
Created June 22, 2015 13:33
Show Gist options
  • Save sinky/dce4cc4e1268cc7eb92a to your computer and use it in GitHub Desktop.
Save sinky/dce4cc4e1268cc7eb92a to your computer and use it in GitHub Desktop.
Load jQuery if not present
(function() {
function init(ownjQuery) {
var $ = jQuery;
console.log('jQueryFy');
}
if(typeof jQuery === "undefined") {
loadScript('//code.jquery.com/jquery.js', function() {
init(true);
});
}else{
init(false);
}
function loadScript(u, c) {
var d = document,
o = d.createElement('script');
o.src = u;
if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
d.getElementsByTagName('head')[0].appendChild(o);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment