Forked from benbalter/conditionally-load-jquery.js
Last active
August 29, 2015 14:02
-
-
Save Nilpo/91ce50041d0c3471d7f2 to your computer and use it in GitHub Desktop.
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
// Conditionally Load jQuery (javascript) | |
// Source: https://gist.github.com/gists/902090/ | |
var init, loadjQuery; | |
init = function() { | |
jQuery(document).ready(function() { | |
alert('Your Code Here'); | |
}); | |
}; | |
loadjQuery = function() { | |
var jQ; | |
if (!(typeof jQuery !== "undefined" && jQuery !== null)) { | |
jQ = document.createElement('script'); | |
jQ.type = 'text/javascript'; | |
jQ.onload = jQ.onreadystatechange = init; | |
//jQ.src = '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; | |
jQ.src = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'; | |
return document.body.appendChild(jQ); | |
} else { | |
return init(); | |
} | |
}; | |
if (window.addEventListener) { | |
window.addEventListener('load', loadjQuery, false); | |
} else if (window.attachEvent) { | |
window.attachEvent('onload', loadjQuery); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment