Last active
February 14, 2019 00:53
-
-
Save kyletaylored/e587993a562555becc24986852e7dba5 to your computer and use it in GitHub Desktop.
Load scripts with JS
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
// Load JS function | |
var loadJS = function(url, callback){ | |
var scriptTag = document.createElement('script'); | |
scriptTag.src = url; | |
scriptTag.onload = callback; | |
scriptTag.onreadystatechange = callback; | |
document.body.appendChild(scriptTag); | |
}; | |
// Load CSS function | |
var loadCSS = function(url) { | |
var styleTag = document.createElement('link'); | |
styleTag.href = url; | |
styleTag.rel = "stylesheet"; | |
styleTag.type= "text/css"; | |
document.head.appendChild(styleTag); | |
}; | |
jQuery(document).ready(function() { | |
// var protocol = location.protocol; (optional) | |
loadJS('URL', <callback>); | |
loadCSS('URL'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment