Last active
December 13, 2015 23:48
-
-
Save jonathanstark/4993767 to your computer and use it in GitHub Desktop.
Snippet of javascript code that will append external script files programmatically. Intended for responsive web sites where maximum progressive enhancement is desired. Don't want to make needless http requests or load external javascript on devices that can't (or shouldn't) execute javascript. NOT DEPENDENCY SAFE! Scripts will load asynchronousl…
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
<html> | |
<head></head> | |
<body> | |
<!-- All your kewl content goes here --> | |
<!-- Append javascript programatically so we don't make needless http requests --> | |
<script> | |
(function(){ | |
var goodBrowser = function() { | |
// Check for features and return true if browser has everything you need | |
return true; | |
} | |
if(goodBrowser()) { | |
document.write('<script src="./js/script1.js"><\/script>'); | |
document.write('<script src="./js/script2.js"><\/script>'); | |
} | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment