Skip to content

Create service worker from Blob/String URL #578

@h2non

Description

@h2non

I guess it's a security decision, however it could be really useful for better and easier approach when developing generic libraries which needs to abstract implementation details to end developers which uses the ServiceWorker to provide functionalities such as transpartent assets caching or HTTP traffic interceptor/modification on the flight

Taking a look to its parent implementations (Workers and SharedWorkers), any developer can create them using different ways to dynamically serialize code and transforming it as a binary. I think that the same feature for service workers will be great match. The scope limitation has no sense in this cases

A basic example:

var workerBlob = new Blob([ serviceWorkerFn.toString() ], { type: 'text/javascript' })
navigator.serviceWorker.register(URL.createObjectURL(workerBlob))
  .then(function () { ... })
  .catch(function () { ... })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions