Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to execute 'importScripts' on 'WorkerGlobalScope' #4

Open
Risingson opened this issue Jan 7, 2021 · 2 comments
Open

Failed to execute 'importScripts' on 'WorkerGlobalScope' #4

Risingson opened this issue Jan 7, 2021 · 2 comments

Comments

@Risingson
Copy link

I don't know what i am doing wrong but whatever i do i get a

Uncaught SyntaxError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL 'something.js' is invalid

error. Am i missing something. Should i be able to use importScripts with this?

@deebloo
Copy link
Owner

deebloo commented Jan 7, 2021

as far as I know it should work. Does importScripts need to be an absolute path?

@Risingson
Copy link
Author

Risingson commented Jan 7, 2021

i think it needs the blob path since inline. but am still researching...
Currently reading here: https://www.html5rocks.com/en/tutorials/workers/basics/
Further down there is a chapter called "Loading External Scripts". It says:

"When using these techniques to inline your worker code, importScripts() will only work if you supply an absolute URI. If you attempt to pass a relative URI, the browser will complain with a security error. The reason being: the worker (now created from a blob URL) will be resolved with a blob: prefix, while your app will be running from a different (presumably http://) scheme. Hence, the failure will be due to cross origin restrictions."

But am not sure if that is the reason. I am using this for a mobile app so it needs to work in a file: environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants