Skip to content

Instantly share code, notes, and snippets.

View sveinho's full-sized avatar

Svein Høier sveinho

  • Norwegian University of Science and Technology
  • Trondheim
  • 10:10 (UTC -12:00)
View GitHub Profile
@sveinho
sveinho / sustainable-json-ld.html
Created December 5, 2025 12:42 — forked from aristath/sustainable-json-ld.html
Research generating HTML from JSON-LD. Avoids content duplication, reducing the overall data transferred to clients. We only transfer the JSON-LD object, and then add a script to generate the HTML from it. The JS can be enqueued as an external asset so it gets cached browser-side. This is just a proof of concept.
<!-- Add a wrapper div. The content we generate from JSON-LD will be rendered here.-->
<div id="content-wrapper" style="max-width:70ch;margin-left:auto;margin-right:auto;"></div>
<!-- The JSON-LD of our recipe. -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Recipe",
"mainEntityOfPage": "https://www.allrecipes.com/recipe/12682/apple-pie-by-grandma-ople/",
"name": "Apple Pie by Grandma Ople",