Created
August 20, 2013 09:30
-
-
Save thekarel/6279307 to your computer and use it in GitHub Desktop.
Asyc loading script tag generating function
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
// Asynchronously load and execute a script from a specified URL | |
// Lifted from JavaScript: The Definitive Guide, 6th edition, p. 320 | |
function loadasync(url) { | |
var head = document.getElementsByTagName("head")[0]; // Find document <head> | |
var s = document.createElement("script"); // Create a <script> element | |
s.src = url; // Set its src attribute | |
head.appendChild(s); // Insert the <script> into head | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment