Created
June 22, 2015 13:33
-
-
Save sinky/dce4cc4e1268cc7eb92a to your computer and use it in GitHub Desktop.
Load jQuery if not present
This file contains 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
(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