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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#