InterviewStack.io LogoInterviewStack.io

DOM Manipulation and Browser APIs Questions

Programming the browser platform: the Document Object Model, traversal and mutation, event handling and the event model, and the wider set of browser and web-platform APIs. Covers manipulating rendered pages and reasoning about browser internals without relying on a framework. A core frontend interview surface.

MediumTechnical
79 practiced

Write a MutationObserver in vanilla JavaScript that observes a container with id 'feed' for newly added nodes. For each added node with class 'article' add role='article' and a unique aria-label (e.g., 'article-<counter>'). After processing 50 articles, the observer must automatically disconnect to avoid overhead. Include error handling and explain performance implications.

MediumTechnical
72 practiced

Design a lazy-loading image system using IntersectionObserver. Provide code to observe images, set the src when an image becomes visible, unobserve after load, and sketch a fallback for browsers without IntersectionObserver (e.g., scroll+throttle). Also outline an infinite-scroll sentinel pattern for loading more items.

HardTechnical
81 practiced

Explain how event retargeting works with Shadow DOM. Describe how events that originate inside a shadow root appear to listeners outside the root, the role of event.composed and event.composedPath(), and the implications for common event delegation patterns when using web components. Provide example code demonstrating how to access the original internal target.

MediumTechnical
94 practiced

Refactor the following pattern for performance: for (let i = 0; i < items.length; i++) { const el = document.querySelector('.item-' + i); process(el); } Explain why repeated document.querySelector calls inside the loop are costly and give an optimized alternative suitable for very large lists. Provide code sample and complexity analysis.

MediumTechnical
94 practiced

Implement a debounce function in JavaScript that supports leading and trailing invocation options and provides a cancel method. Describe the difference between debounce and throttle and give two concrete scenarios where you would use debounce versus throttle.

Unlock Full Question Bank

Get access to all DOM Manipulation and Browser APIs interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.