Last active
September 23, 2017 20:47
-
-
Save Sanix-Darker/6feb114deec64ac1bbc8242f8dd12d9b to your computer and use it in GitHub Desktop.
[JS] How to check if jQuery is not already, loaded and call it
This file contains hidden or 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 myJQueryCode() { | |
| //Do stuff with jQuery | |
| } | |
| if(typeof jQuery=='undefined') { | |
| var headTag = document.getElementsByTagName("head")[0]; | |
| var jqTag = document.createElement('script'); | |
| jqTag.type = 'text/javascript'; | |
| jqTag.src = 'jquery.js'; | |
| jqTag.onload = myJQueryCode; | |
| headTag.appendChild(jqTag); | |
| } else { | |
| myJQueryCode(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment