Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

264
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!