Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

270
Vistas
Why can't I import in Javascript service worker?

So I have a service worker in order to implement FCM to my web app, and I can't fix the following issue.

This is my code:

importScripts("https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-app-compat.min.js", "https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-messaging-sw.min.js")

const firebaseApp = initializeApp({
  ...
});

getMessaging(firebaseApp);

console.log('Firebase messaging service worker is set up');

And these are the issues I get in the console

Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-app-compat.min.js' failed to load.

Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-messaging-sw.min.js' failed to load.

Any solutions?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Put the file that contain this script in public directory and try next script.

self.importScripts("https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-app-compat.min.js", "https://cdnjs.cloudflare.com/ajax/libs/firebase/9.6.9/firebase-messaging-sw.min.js")
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda