Last active
August 23, 2016 17:07
-
-
Save SmugZombie/7785125a86ef4e8488414cd0991dd28a to your computer and use it in GitHub Desktop.
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 include(type, source){ | |
| //Includes external resources via injection | |
| var head = document.getElementsByTagName('head')[0]; | |
| switch(type){ | |
| case 'js': { | |
| resource = document.createElement('script'); | |
| resource.type = 'text/javascript'; | |
| resource.src = source; | |
| break; | |
| } | |
| case 'css': { | |
| resource = document.createElement('link'); | |
| resource.rel = 'stylesheet'; | |
| resource.type = 'text/css'; | |
| resource.href = source; | |
| break; | |
| } | |
| } | |
| console.log('Included ' + type + ': ' + source); | |
| head.appendChild(resource); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment