Support import statements in Service Workers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 10:37 AM
Most major browsers support the use of ECMAScript import statements in the Service Worker by declaring { type: 'module' } when registering the Service Worker script.
This:
// in main script
navigator.serviceWorker.register("service-worker.js", {
type: "module",
})
Enables:
// in service-worker.js
import "path/to/this.js"
import { that } from 'path/to/that.js'
import * as theOtherThing from 'path/to/theOtherThing.js'
// ...
Unfortunately Firefox does not support this functionality for Service Workers. This was disappointing because I had intended to package my Service Worker code for a notification-based library as ECMA modules.
A similar feature was implemented for Web Workers two years ago.
Is FF actively working on this functionality for Service Workers?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 09:19 AM - edited 03-21-2025 10:15 AM
Firefox's lack of support for ECMAScript import statements in Service Workers is indeed frustrating, especially since other major browsers have implemented this functionality. Given that Web Workers gained module support two years ago, it's surprising that Service Workers are still left behind. This limitation makes it difficult to maintain clean, modular code, particularly for use cases like notification-based libraries. Firefox should prioritize adding this feature to stay aligned with modern web development practices. If you're developing with Service www.alexandrialimos.com Workers, consider testing in Chromium-based browsers or checking Mozilla's roadmap for updates.
Thanks!

