Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created August 20, 2013 09:30
Show Gist options
  • Save thekarel/6279307 to your computer and use it in GitHub Desktop.
Save thekarel/6279307 to your computer and use it in GitHub Desktop.
Asyc loading script tag generating function
// 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