Back to feed
Dev.to
Dev.to
7/21/2026
How MV3 Service Workers Made Me Use an Offscreen Document Just to Play a Goat Sound

How MV3 Service Workers Made Me Use an Offscreen Document Just to Play a Goat Sound

Short summary

A developer explains how Manifest V3's service worker architecture forced them to use Chrome's offscreen document API just to play a sound in a Chrome extension. MV3 service workers have no DOM access, so audio playback requires creating a hidden HTML page that handles the actual Audio() call. The post also covers how chrome.alarms replaces setTimeout since service workers can be killed at any time, making persistent timers unreliable.

  • MV3 service workers cannot play audio — you need the offscreen document API with reasons: ['AUDIO_PLAYBACK']
  • chrome.alarms is the only reliable way to schedule future tasks since service workers are disposable
  • Core MV3 lesson: design around the assumption that your background script can be killed at any time

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more