Write script tags to the document head
Here's a quick function that I've used lots of times to write script tags to the head of a document without the use of libraries:
function appendScriptTag(path) {
var head = document.getElementsByTagName('head')[0],
script = document.createElement('script');
script.type = 'text/javascript';
script.src = path;
head.appendChild(script);
}
Written by Matt Kaye
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Dom
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#