Hacker News new | ask | show | jobs
by cousin_it 48 days ago
Yeah. I want to note quickly that the currentScript method can do a bit more than that. For example, the page head can include script.js with the code for rendering the site shared header and footer. Then in the page body you can have inline scripts using the currentScript trick to add the header and footer in place, kinda like including shared templates. And it runs during page load, before even onLoad, so the page renders with header and footer straight away.
1 comments

Agreed! And you aren't even restricted to currentScript; you can run arbitrary JS in an XML document, reformatting it however you like.