What is a web worker?

Learn web design with our comprehensive test guide. Improve your skills with flashcards and multiple choice questions. Each question includes hints and explanations. Get ready to ace your exam!

Multiple Choice

What is a web worker?

Explanation:
Web workers let JavaScript run in a separate background thread so the main page stays responsive. They take on CPU-heavy tasks without blocking rendering or user interactions, because they run independently from the code that updates the UI. They can’t access the page’s DOM directly, which is why they need to communicate with the main thread using messages (postMessage and onmessage). This setup is why the description that fits best is a JavaScript running in the background, without affecting the performance of the page. Other options aren’t quite right because they describe timing or environments that aren’t accurate for web workers: one talks about running only after user interaction, which isn’t a defining trait; another says it runs on the server, which isn’t true since web workers are client-side; and another mentions a CSS feature, which isn’t related to how web workers work.

Web workers let JavaScript run in a separate background thread so the main page stays responsive. They take on CPU-heavy tasks without blocking rendering or user interactions, because they run independently from the code that updates the UI. They can’t access the page’s DOM directly, which is why they need to communicate with the main thread using messages (postMessage and onmessage). This setup is why the description that fits best is a JavaScript running in the background, without affecting the performance of the page.

Other options aren’t quite right because they describe timing or environments that aren’t accurate for web workers: one talks about running only after user interaction, which isn’t a defining trait; another says it runs on the server, which isn’t true since web workers are client-side; and another mentions a CSS feature, which isn’t related to how web workers work.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy