Created
December 29, 2014 19:45
-
-
Save ianaya89/3aedf3308603135bf69b to your computer and use it in GitHub Desktop.
Add jQuery to any page that does not have it already.
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() { | |
if ( !window.jQuery ) { | |
var $inUse = !!window.$, | |
script = document.createElement('script'); | |
script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js'); | |
script.addEventListener('load', function(){ | |
console.log('jQuery was loaded.'); | |
if ($inUse) { | |
jQuery.noConflict(); | |
console.log('jQuery was loaded in noConflict mode, use jQuery instead \'$\' '); | |
} | |
}); | |
document.body.appendChild(s); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment