The head tag can be referenced directly
Older methods of adding elements to the head of a document would search the document by tag names. Now a days you can reference head directly on document:
const script = document.createElement("script")
document.head.appendChild(script)
Older methods relied on document.getElementsByTagName("head")[0]