
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.
gemmaI ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...
communityHey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...
ai(yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...
aiMy laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...
githubactionsI Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...
aiI've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...
Workflows from the Neura Market marketplace related to this DeepSeek resource