Using airgap.js in web workers

airgap.js 9.28 and later can protect web workers and worklets.

airgap.js does not yet support consent sync within protected worker threads. This means that quarantined events aren’t replayed when consent changes outside the worker's realm, so quarantined events are effectively blocked.

In order to apply airgap.js protections without our realm auto-protection hooks, use the following snippets:

self.airgap = {
  loadOptions: {
    airgap: '[location of airgap.js]',
    baseUrl: '[URL of the original worker script]',
  },
};

Classic worker

importScripts(self.airgap.loadOptions.airgap);

Module worker or worklet

await import(self.airgap.loadOptions.airgap);