worker-dom icon indicating copy to clipboard operation
worker-dom copied to clipboard

script elements

Open cramforce opened this issue 7 years ago • 1 comments

We need to design/decide what adding a script elements via worker-dom does. This may also need to be configurable.

Currently it would just do it and execute the script on the main thread. Which would be right for some use cases. But for other cases, such as when using code splitting, one might want to run the script inside the worker.

In that case, we may "neuter" the script element and instead use importScript to load the script. I believe that importScript is sync, so we may need to instead fetch the script and then call importScript with a blob (is that supported?)

cramforce avatar Aug 30 '18 00:08 cramforce

Good point.

We already have the hooks to do most of this work, registering a class to extend Element for script tagNames.

Early idea: If the script element is inserted into the head of the document, then we can fetch and importScript into the worker. If the element is inserted into the body, then its expected to run in both the main thread and the worker thread.

kristoferbaxter avatar Aug 30 '18 15:08 kristoferbaxter