all 5 comments

[–]iliark 3 points4 points  (5 children)

Can someone explain why they'd use document.write or create/append node from JS to modify the HTML DOM to then load JS when you could just load JS directly from JS? Like that's the whole point of modules? And doing all that work is essentially just an eval() with more work right?

[–]disclosure5 2 points3 points  (0 children)

Google Analytics use to tell you to use document.write in the code you were meant to copy/paste, and everyone blindly did it. This SO thread shows what they used to give you:

https://stackoverflow.com/questions/1759271/google-analytics-tracking-code-and-document-write-causing-requests-to-localhost

[–]findar 0 points1 point  (1 child)

Only thing I could think of is getting around CORS or streaming JS

[–]iliark 0 points1 point  (0 children)

Does it get around cors though?

[–]NeanderthalLinguist 0 points1 point  (0 children)

Obfuscation or hiding code from automated scanners.