Skip to main content
InterviewHubPRO
Section Overview
Q33

Question 33 of 50

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

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

Web Components Lifecycle Hooks.

senior LevelComponentsHooksLifecycle

In Simple Words: The 4 native lifecycle callback methods of custom elements:

  1. connectedCallback(): Invoked each time the custom element is appended into a document-connected DOM tree. (Initialize listeners, fetch data).
  2. disconnectedCallback(): Invoked when removed from the DOM. (Clean up timers and event listeners).
  3. adoptedCallback(): Invoked when moved to a new document (e.g. across <iframe> boundaries).
  4. attributeChangedCallback(name, oldValue, newValue): Invoked when an observed attribute (listed in static get observedAttributes()) is updated.