Comment by cousin_it

6 hours ago

When I first learned that XSLT was going away, I got curious how to achieve the same thing in JS (client-side templating that happens during page load, without any "flash of content"). It turns out there's a very nice way to do it, by using inline scripts that append elements next to document.currentScript. Lean Rada wrote about it here: https://leanrada.com/notes/inline-rendering-currentscript/ and I wrote about it as well: https://vladimirslepnev.me/write

Instead of:

    <script>document.currentScript.replaceWith(new Date().getFullYear())</script>

How about:

    <svg onload="this.outerHTML=new Date().getFullYear()"/>

Not as pretty, and you'd have to escape all the quotes, but still pretty usable.