CodePark/ questions / Web workers & service workers
START PRACTICINGPRACTICE
Frontend question · Browser & web performance › Web workers & service workers

Which of these can a dedicated web worker NOT use?

document.querySelector

Workers have no access to the DOM or document, so document.querySelector doesn't exist there.

fetch, setTimeout and IndexedDB are tempting wrong answers, because people think workers can do very little. In fact, workers can use fetch, timers, IndexedDB and many other APIs. To change the page, the worker sends its results back with postMessage, and the page updates the DOM.