Skip to content

feat(demo): Run js in worker in wat2wasm demo#2568

Merged
sbc100 merged 2 commits intoWebAssembly:mainfrom
spotandjake:spotandjake-demo-worker
Mar 15, 2026
Merged

feat(demo): Run js in worker in wat2wasm demo#2568
sbc100 merged 2 commits intoWebAssembly:mainfrom
spotandjake:spotandjake-demo-worker

Conversation

@spotandjake
Copy link
Copy Markdown
Contributor

This pr moves execution of the user js and wasm module from the main page to a web worker. The benefit of this is if you write an infinite loop in either the js or wasm you won't crash the main page and can recompile. I also added a Run button as I noticed there wasn't one and it was useful for testing (when you edit the wasm the output doesn't update until you click run or edit the js).

NOTE

As the js is now running in a worker it is isolated so while before you could have worked with the dom from the js editor you can't really do this anymore. I feel like the old behaviour didn't make much sense anyways though.

@spotandjake spotandjake force-pushed the spotandjake-demo-worker branch from 91a8e44 to b67fde0 Compare March 22, 2025 00:42
@spotandjake
Copy link
Copy Markdown
Contributor Author

Hope I'm not bugging anyone, but any chance I could get a review on this?

Copy link
Copy Markdown
Member

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

Seems like it might be overkill for a simple demo but if you find it useful to be able to avoid blocking the main page then lgtm.

Its been while since we changed this I think.. do you know how we publish the new version? Is it automatic?

Comment thread docs/demo/wat2wasm/worker.js Outdated
Comment thread docs/demo/wat2wasm/worker.js
@spotandjake spotandjake force-pushed the spotandjake-demo-worker branch from b67fde0 to 40913ce Compare December 14, 2025 02:24
@spotandjake
Copy link
Copy Markdown
Contributor Author

spotandjake commented Dec 14, 2025

Fair enough!

Seems like it might be overkill for a simple demo but if you find it useful to be able to avoid blocking the main page then lgtm.

Its been while since we changed this I think.. do you know how we publish the new version? Is it automatic?

I know that this is just a demo however I know myself and others in the wasm community sometimes use this tooling to explore the spec and play around hands on with wasm in a convient and quick manner.

I wasn't around the last time this was updated and can't find any specific workflows for it however I did notice that github pages seems to run on every commit to main logs here so it seems like this should just get updated.

Seperatly though this is probably best discussed in another issue it might make sense to run make demo on release to regenerate the libwabt.js file.

Thankyou for the review.

@kevmoo
Copy link
Copy Markdown
Contributor

kevmoo commented Mar 14, 2026

Noted this was approved but never landed?

@spotandjake
Copy link
Copy Markdown
Contributor Author

I think this is good to be merged, I think it was never landed because of @sbc100's queston about the release process.

I'll make an issue about updating libwabt.js with make demo on release once this is merged.

@sbc100 sbc100 merged commit 6aac429 into WebAssembly:main Mar 15, 2026
17 checks passed
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.

3 participants