Reputation: 1141
I need to include some scripts in to my service worker. Normally we are appending scripts to DOM using document object. But in the case of service workers there is no DOM. So how can we do this using JS codes?
Thanks..
Upvotes: 1
Views: 749
Reputation: 2350
Use the importScripts function. you can host your js files on an https domain and do something like this:
importScripts("//cdn.jsdelivr.net/pouchdb/5.3.1/pouchdb.min.js");
Upvotes: 2