Lesson content
Read, practise, then check your understanding
Web APIs extend JavaScript with browser capabilities. Workers run in separate realms without direct DOM access and communicate using structured-clone messages and transferable objects.
Observe without polling
const observer = new IntersectionObserver(entries => {
for (const entry of entries) {
if (entry.isIntersecting) loadPreview(entry.target);
}
});
observer.observe(document.querySelector("[data-preview]"));
MutationObserver reports DOM changes; ResizeObserver reports element size; WebSocket provides full-duplex messages; BroadcastChannel communicates same-origin contexts. Geolocation, notifications, media, clipboard, and other powerful APIs require secure contexts and permissions. Feature-detect, handle denial, clean up observers/connections, and bound incoming data.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.