Skip to main content
InterviewHubPRO
Section Overview
Q42

Question 42 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

84%
HTML5 & Web APIs (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Declarative Shadow DOM: Server-Side Rendering (SSR) for Web Components.

senior LevelCode ExampleComponentsSSR & HydrationSystem Design

In Simple Words: Historically, Shadow DOM required JavaScript (attachShadow()) to render, causing layout shift and rendering delays during SSR. Declarative Shadow DOM allows servers to output pre-rendered Shadow roots directly in pure HTML using <template shadowrootmode="open">:

html
<user-card>
  <template shadowrootmode="open">
    <style>
      .card { border: 1px solid #ccc; padding: 1rem; border-radius: 8px; }
    </style>
    <div class="card">
      <slot name="username">Anonymous</slot>
    </div>
  </template>
  <span slot="username">Jane Doe</span>
</user-card>