Created
June 11, 2020 02:38
-
-
Save djD-REK/c242a0136310bb9a65e1554e4f4480a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const script = document.createElement("script") | |
script.type = "text/javascript" | |
script.src = "script.js" | |
document.head.appendChild(script) | |
eval(script) |
Thanks for the correction @likev!
You're absolutely right, eval() or Function() are totally optional unless you need to import the script as a string -- or for example are loading the text <script src="..."> and need to evaluate that statement.
I updated the article:
https://levelup.gitconnected.com/how-to-load-external-javascript-files-from-the-browser-console-8eb97f7db778
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there is no need to use
eval(script)
instead you should use
or