
When I started this experiment, the core question was simple: Because content inside...
title: Content Virtualization using the HTML <template> Element published: true description: tags: html, javascript, performance, AI cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5mr656i4ly8u7ec2c65v.png
When I started this experiment, the core question was simple:
Because content inside
<template>is inert, can I page HTML into templates and add/remove it from the DOM to improve performance while still making it available for bots and content scrapers?
The answer is yes, but with important caveats.
I built four tests around the same dataset of 100,000 items and compared how they behave when rendering a very large list of rich rows.
Each demo represents a different tradeoff between startup cost, live DOM size, implementation complexity, content visibility, and crawler/scraper behavior.
Demo: No Virtualization
This is the baseline worst case: all rows are shipped in the initial HTML and remain live in the DOM.
This is the best option for maximum content visibility, but the worst for browser performance at large scale.
Demo: Paged Templates
This version ships all rows in the initial HTML, but stores most of them inside <template> elements so they stay inert until mounted.
<template> content is inert and not normally rendered page content.Template virtualization is viable, but it improves runtime DOM cost more than startup cost. In this test, AI parsing behaved much better than expected because the static source still contained the inert template content.
Demo: JS Virtualization
This version keeps the data in JavaScript and reuses a small pool of row nodes while scrolling.
If the goal is browser UI performance, this is usually the strongest default. If the goal is content discoverability, it is usually the weakest.
Demo: Lazy Paged Templates
This version keeps the template model, but creates template pages after the initial page loads instead of shipping them all up front.
This is the most interesting template-based approach I tested. It keeps the inert template idea while avoiding the biggest flaw of the static template version, but it is still less reliable than plain HTML for indexing and scraping.
Here is the practical ranking from this experiment:
| Approach | Browser performance | SEO / indexing | Basic scraping | Source-based AI analysis |
|---|---|---|---|---|
| No Virtualization | Worst | Best | Best | Best |
| Paged Templates | Better than full live DOM, but still heavy at startup | Mixed-to-good | Good | Good |
| JS Virtualization | Best | Weakest | Weakest | Weakest |
| Lazy Paged Templates | Better startup than static templates | Mixed-to-weak | Weak | Weak |
I ran a simple AI discoverability test against each example.
I asked the AI (claude code and copilot) how many times it could find the name "Avery Adams" on the page. The correct answer is 391.
| Example | Correctly counted names |
|---|---|
| No Virtualization | ✅ |
| Paged Templates | ✅ |
| JS Virtualization | ❌ |
| Lazy Paged Templates | ❌ |
This result was notable because AI systems often use tools like curl to inspect a page's static response. In this case, the AI did not appear to ignore content inside <template> tags. That made Paged Templates much more discoverable to source-based AI analysis than a pure JS-rendered approach.
The lazy template version did not fare as well, because much of its content is created after the initial response rather than being present in the original HTML source.
Template virtualization could be a viable approach to improve performance and still make content available for static analysis, but it may not be the best tool for it.
aiMost of us have seen a coding agent fail to complete a task we know it can do. We just don't...
googlecloudWhen building Generative AI applications, developers often encounter a massive bottleneck: sequential...
discussI’ve been thinking about sharing some electronic circuit posts on Dev.to — small circuits, DIY...
agentsWhat nobody tells you about exporting your multi-agent prototype to a local workspace. Every...
agenticarchitectAutonomous agents are genuinely good at answering messy business questions. Give one an LLM and a set...
aiPR volume went up, ticket quality didn't, and the gap got filled with LLMs on both sides of the review: bots reviewing, bots replying, bots occasionally arguing with bots about priorities that only existed in a teammate's head. Our CEO named the actual problem, and it's bigger than code review.
Workflows from the Neura Market marketplace related to this Stable Diffusion resource