News for hackers. Stuff that matters.
Re:Why Not Document.write()? by bastawhiz on Saturday April 01, 2023 @10:12PM (#35406423)
Your server is already running a scripting language. Putting a script tag on the page necessarily means the browser then needs to parse and interpret some JavaScript, which it simply wouldn't otherwise need to do. If we assume the server and the client both execute an if statement at the same speed, yes, it's purely adding overhead to run that on the client (not to mention the potential for the additional cost of transmitting the eliminated code).
Re:Why Not Document.write()? by theendisney on Sunday April 02, 2023 @01:09AM (#35407383)
Sorry, I thought it was obvious. The overhead is practically zero compared to the amount of html you can comment out.

You can have a cached static html document with really huge (conditional) comments with tiny performance loss. display:none for example still does all kinds of things. Inserting html with js is even worse.