A key part of the article is this block of code that shows how to dynamically add your JavaScript to the DOM. Var newScript documentcreateElement script. Var headID documentgetElementsByTagName head 0.