English for Web Components Developers
Master the vocabulary for discussing custom elements, shadow DOM, slots, and templates in English at work.
Web Components bring a native component model to the browser, but they also introduce a specialised vocabulary that trips up many non-native English speakers in technical discussions. Terms like “shadow DOM,” “slots,” and “lifecycle callbacks” have very precise meanings in this context, and using them correctly signals expertise during code reviews and architecture discussions. This guide gives you both the definitions and the natural English phrases that experienced web component developers reach for every day.
Key Vocabulary
Custom element
A user-defined HTML element registered with customElements.define(). Custom elements extend the browser’s built-in element vocabulary with reusable, encapsulated components.
Example: “We registered a custom element called <user-avatar> that handles its own image loading and fallback logic.”
Shadow DOM A private, encapsulated DOM subtree attached to a custom element. Styles and scripts inside the shadow DOM do not leak out, and external styles do not leak in by default. Example: “The button styles are scoped to the shadow DOM, so global stylesheets will not accidentally override them.”
Light DOM The regular, public DOM content that a consumer places inside a custom element’s tags — as opposed to the shadow DOM that the component itself manages internally. Example: “The text label is part of the light DOM; the element’s internal icon lives in the shadow DOM.”
Slot
A placeholder element (<slot>) inside a shadow DOM that allows light DOM content to be projected (rendered) into a specific position within the component’s template.
Example: “We have a named slot called actions so consumers can inject buttons into the card footer.”
HTML template (<template>)
A browser-native element whose content is inert (not rendered, not fetched) until it is cloned and inserted into the document. Used as the foundation for shadow DOM structures.
Example: “The component clones the <template> on each instantiation instead of building the DOM manually.”
Lifecycle callbacks
Special methods (connectedCallback, disconnectedCallback, attributeChangedCallback, adoptedCallback) that the browser calls automatically at key points in a custom element’s life.
Example: “We fetch user data in connectedCallback and cancel the request in disconnectedCallback to avoid memory leaks.”
Observed attributes
The static list of attribute names returned by observedAttributes that tells the browser which attribute changes should trigger attributeChangedCallback.
Example: “We added theme to the observed attributes so the component re-renders when the attribute is updated from outside.”
Encapsulation The principle by which a component hides its internal structure and styles from the rest of the page. Shadow DOM is the mechanism that enforces encapsulation in Web Components. Example: “The shadow DOM enforces encapsulation — consumers interact only through properties and slots, not internal nodes.”
Common Phrases
In code reviews:
- “This styles the host element from the outside using
::part()— make sure the part name is documented in the component’s API.” - “You are querying
document.querySelectorinside the component — usethis.shadowRoot.querySelectorto stay within the shadow boundary.” - “The slot fallback content will show when the consumer provides nothing, but it needs a proper accessible label.”
In standups:
- “I finished wiring up the named slots for the dialog component — consumers can now inject custom footers without touching the internals.”
- “I am investigating a flash of unstyled content on first paint; it seems the shadow DOM is not attached before the element is visible.”
- “Yesterday I added
attributeChangedCallbackfor thedisabledattribute; today I will write the observed-attributes unit tests.”
In documentation:
- “Consumers interact with this element through its public properties and named slots; the shadow DOM internals are not part of the API contract.”
- “Observed attributes are limited to
variant,size, anddisabled— other configuration should be passed as JavaScript properties.” - “Do not apply styles directly to internal shadow DOM nodes; use CSS custom properties (variables) exposed through the component’s API instead.”
Phrases to Avoid
Saying “the shadow DOM is like an iframe.” This is a common non-native comparison that causes confusion. An iframe is a fully separate browsing context with its own JavaScript environment. The shadow DOM is just a scoped subtree of the same document. Say: “The shadow DOM creates a style boundary, not a full isolation context like an iframe.”
Saying “I put the content in the slot” when you mean you defined a slot. In English, a developer defines or declares a slot inside the component. A consumer fills or projects content into a slot. “I added a slot” means you created the placeholder; “I slotted in a button” or “I projected a button into the slot” means you put content into it.
Saying “lifecycle hooks” instead of “lifecycle callbacks.” “Hooks” in front-end English is closely associated with React Hooks. Web Components use the term “lifecycle callbacks” (or “lifecycle methods”) in official specifications and documentation. Using “hooks” in this context may confuse teammates into thinking you mean a framework feature.
Quick Reference
| Term | How to use it |
|---|---|
| custom element | ”We registered a custom element to encapsulate the date-picker logic.” |
| shadow DOM | ”Styles inside the shadow DOM do not bleed into the rest of the page.” |
| slot | ”The <slot name='footer'> lets consumers inject action buttons.” |
| lifecycle callback | ”Clean up timers in disconnectedCallback to prevent memory leaks.” |
| observed attributes | ”Add color to observedAttributes so changes trigger a re-render.” |