Inline rendering with document.currentScript
17th October 2026 - Link Blog
Inline rendering with document.currentScript. Lean Rada describes a neat trick that takes advantage of the property. You can use that to drop in a tiny inline <script> element that replaces itself when the page loads:
The year is <script>
document.currentScript.replaceWith(
new Date().getFullYear())</script>
If you define a shortcut function like this:
$=(...n)=>document.currentScript.replaceWith(...n)
You get a tiny template language:
The year is <script>$(new Date().getFullYear())</script>
讲解得很细致,新手也能看懂。
点赞,必须点赞
这个比较实用,已转发给同事。
点赞,必须点赞
看完了,收获满满,期待更多更新。
很有价值的分享,感谢整理。
实话,说的不明不白
这个比较实用,已转发给同事。
赞同,实践出真知。
内容翔实,正好需要,先收藏再看。
实测过类似工具,作者说的基本属实。
支持作者,持续关注中。