In this case, another option is to define another shortcut for documents other than document. For example, you can move the $ function definition inside a function that takes a document as a parameter:
document
function insertScriptIntoDocument(doc, jsfile) { const $o = doc.querySelector.bind(doc) const script = document.createElement('script') script.setAttribute('src', jsFile) $o`head`.insertAdjacentHTML('beforeEnd', script) }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In this case, another option is to define another shortcut for documents other than
document
. For example, you can move the $ function definition inside a function that takes adocument
as a parameter: