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

Web worker thread for performance boost #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kangzeroo
Copy link
Owner

@kangzeroo kangzeroo commented Jun 27, 2021

🤔 Originally I wanted to use a web-worker to offload JS work from the main thread so that this widget would be non-intrusive & high performance. This can be useful because some companies may be hesitant to add an embed widget to their website if the main JS thread is busy. In theory, offloading work to a separate web-worker JS thread would give a performance boost as the main JS thread is barely touched by this widget.

However in practice 🤣 loading a web-worker from a cross-origin CDN is actually a XSS security vulnerability as explained by the W3C team here in w3c/ServiceWorker#940 (comment)

There are 2 possible workarounds, but they add extra complexity and might not be worth enough juice for the squeeze:

  1. Load the widget as an iframe and load the webworker in the same iframe so that its the same origin (from CDN)
  2. Keep the widget NOT an iframe and instead load the webworker as base64 and convert into a script

@kangzeroo kangzeroo self-assigned this Jun 27, 2021
@kangzeroo
Copy link
Owner Author

I intend to close this pull request and keep things simple for now, just keep the entire script in the same thread.

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

Successfully merging this pull request may close these issues.

1 participant