Server-render HTML + encapsulated styles before JavaScript boots
This example demonstrates a practical combo: SSR output for immediate content + Declarative Shadow DOM for style encapsulation without waiting for client rendering.
The cards below are rendered in HTML with <template shadowrootmode="open">, then upgraded with minimal JS.
Typical HTML the server can stream immediately:
<product-preview>
<template shadowrootmode="open">
<style>/* isolated card styles */</style>
<article class="card">
<slot name="name"></slot>
<slot name="meta"></slot>
<button id="quickAdd">Quick add</button>
</article>
</template>
<h3 slot="name">Keyboard KX-87</h3>
<p slot="meta">$129 · Stock: 24</p>
</product-preview>
Buttons are wired after load to prove progressive enhancement / hydration style behavior.
[ready] waiting for actions…