Find a live version on Netlify.
This is a simple setup that demonstrates the use of web workers in Sveltekit. Most parts apply to any framework.
Web workers allow you to run a task in a separate process from the rest of the website. This prevents the website from hanging and not allowing any user interaction.
Things you need to know to understand this demo
The interesting files are src/routes/+page.svelte
and src/lib/workers/worker.js
.
Once you've created a project and installed dependencies with bun install
(or npm install
), start a development server:
bun run dev