Web workers allow JavaScript scripts to run in background threads separate from the main execution thread of a web page in order to perform CPU-intensive tasks to avoid blocking the user interface. A worker is created using the Worker() constructor and messages can be sent between workers and the main thread using postMessage() and adding event listeners. Workers have some restrictions like not having direct access to the DOM.