{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/simonwillison-net/2026-10-17-inline-rendering-with-document-currentscript/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "**[Inline rendering with document.currentScript](https://leanrada.com/notes/inline-rendering-currentscript/)**. Lean Rada describes a neat trick that takes advantage of the [document.currentScript](https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript) property. You can use that to drop in a tiny inline `<script>` element that replaces itself when the page loads:\n\n```\nThe year is <script>\ndocument.currentScript.replaceWith(\n  new Date().getFullYear())</script>\n```\n\nIf you define a shortcut function like this:\n\n```\n$=(...n)=>document.currentScript.replaceWith(...n)\n```\n\nYou get a tiny template language:\n\n```\nThe year is <script>$(new Date().getFullYear())</script>\n```\n",
  "authors": [],
  "captured_at": "2026-10-18T06:32:49.699637230+00:00",
  "category": "programming",
  "content_html": "<p><strong><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://leanrada.com/notes/inline-rendering-currentscript/\">Inline rendering with document.currentScript</a></strong>. Lean Rada describes a neat trick that takes advantage of the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript\">document.currentScript</a> property. You can use that to drop in a tiny inline <code>&lt;script&gt;</code> element that replaces itself when the page loads:</p>\n<pre><code><span class=\"code-snippet\">The year is &lt;script&gt;\ndocument.currentScript.replaceWith(\n  new Date().getFullYear())&lt;/script&gt;\n</span></code></pre>\n<p>If you define a shortcut function like this:</p>\n<pre><code><span class=\"code-snippet\">$=(...n)=&gt;document.currentScript.replaceWith(...n)\n</span></code></pre>\n<p>You get a tiny template language:</p>\n<pre><code><span class=\"code-snippet\">The year is &lt;script&gt;$(new Date().getFullYear())&lt;/script&gt;\n</span></code></pre>\n",
  "content_markdown": "**[Inline rendering with document.currentScript](https://leanrada.com/notes/inline-rendering-currentscript/)**. Lean Rada describes a neat trick that takes advantage of the [document.currentScript](https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript) property. You can use that to drop in a tiny inline `<script>` element that replaces itself when the page loads:\n\n```\nThe year is <script>\ndocument.currentScript.replaceWith(\n  new Date().getFullYear())</script>\n```\n\nIf you define a shortcut function like this:\n\n```\n$=(...n)=>document.currentScript.replaceWith(...n)\n```\n\nYou get a tiny template language:\n\n```\nThe year is <script>$(new Date().getFullYear())</script>\n```\n",
  "dateCreated": "2026-10-18T06:32:49.699637230+00:00",
  "date_created": "2026-10-17T21:11:12+00:00",
  "date_modified": "2026-10-17T21:11:12+00:00",
  "date_published": "2026-10-17T21:11:12+00:00",
  "description": "Inline rendering with document​.currentScript Lean Rada describes a neat trick that takes advantage of the document.currentScript property. You can use that to drop in a tiny inline <script> element that replaces itself when the page…",
  "external_url": "https://simonwillison.net/2026/Oct/17/document-currentscript/",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/simonwillison-net/2026/10/2026-10-17-inline-rendering-with-document-currentscript.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/simonwillison-net/2026/10/2026-10-17-inline-rendering-with-document-currentscript.md"
  },
  "id": "urn:aggr:item:96d1c4d1e656150218aac30ee774cd3ddd73accf",
  "isBasedOn": {
    "@id": "https://simonwillison.net/2026/Oct/17/document-currentscript/"
  },
  "mainEntity": {
    "@id": "https://simonwillison.net/2026/Oct/17/document-currentscript/",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/simonwillison-net/2026-10-17-inline-rendering-with-document-currentscript/#webpage"
    },
    "dateModified": "2026-10-17T21:11:12+00:00",
    "datePublished": "2026-10-17T21:11:12+00:00",
    "headline": "Inline rendering with document​.currentScript",
    "timeRequired": "PT1M",
    "url": "https://simonwillison.net/2026/Oct/17/document-currentscript/",
    "wordCount": 70
  },
  "name": "Archived snapshot: Inline rendering with document​.currentScript",
  "preview": null,
  "reading_minutes": 1,
  "replicated_at": null,
  "source": "simonwillison-net",
  "source_name": "Simon Willison's Weblog",
  "summary": "Inline rendering with document​.currentScript Lean Rada describes a neat trick that takes advantage of the document.currentScript 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> Tags: javascript",
  "tags": [
    "javascript"
  ],
  "temporalCoverage": "2026-10-18T06:32:49.699637230+00:00",
  "title": "Inline rendering with document​.currentScript",
  "url": "https://aggr.aymericbeaumet.com/items/simonwillison-net/2026-10-17-inline-rendering-with-document-currentscript/",
  "word_count": 70
}