Inline rendering with document.currentScript
In brief
- Uses `document.currentScript` to replace an inline script with its evaluated result at runtime.
- Enables a tiny template language with a shortcut function like `$`.
- Reduces client-side template complexity without external dependencies.
Simon Willison highlights a JavaScript trick using `document.currentScript` to dynamically replace an inline script with its result when the page loads. This enables building a lightweight template language.
This summary gives you the essentials. The full article, its figures and quotes are on Simon Willison's Weblog.
Read the original articleAI-generated summary of the source, checked by rules. Report an error