Replies: 7 comments 15 replies
-
Did we ever find a reasonable approach for attaching the build options used (optimization level, env, etc), or is the idea here to infer the build options by analyzing the end result? |
Beta Was this translation helpful? Give feedback.
-
The idea would be to find this out as part of the discussion… Some (internal to Google, sorry) commenting happened in this doc. |
Beta Was this translation helpful? Give feedback.
-
For detecting unoptimized Wasm, @connorjclark and @kripken suggest to run |
Beta Was this translation helpful? Give feedback.
-
For detecting Wasm with debug information, you can run |
Beta Was this translation helpful? Give feedback.
-
For detecting Wasm that has not been optimized to run exclusively on the Web, you can check for the non-existence of the following string (it's there if the library was optimized to run exclusively on the Web): throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)') Not sure how robust this would be, though… |
Beta Was this translation helpful? Give feedback.
-
Actually a lot of JS libraries leave traces that tools like Wappalyzer use to detect the presence of said libraries, including version numbers and sometimes more. For example, this is the tool's output for https://emscripten.org/: |
Beta Was this translation helpful? Give feedback.
-
There are a number of things which apps that include WebAssembly (Wasm) code can get wrong, and that Lighthouse could warn about:
When Lighthouse detects a targeted-at-all-environments Wasm file is executed in the browser, print a hint that points at the
-s ENVIRONMENT
option as an optimization opportunity. JavaScript glue code size savings for a "hello world" example: ~5% smaller (-s ENVIRONMENT=web
vs. regular [diff]).When Lighthouse detects an unoptimized Wasm file is executed in the browser, print a hint that points at the optimization options. Wasm code size savings for a "hello world" example: ~83% smaller (
-O3
vs.-O0
).When Lighthouse detects a Wasm file is delivered to production with the
-g
debug option enabled, show a warning message. Wasm code size savings for a "hello world" example: ~95% smaller (regular vs.-g
).Now these savings of course need to be taken with a huge grain of salt and will vary in actually useful code. Find the source code in the accompanying testing repo. It's napkin math that doesn't fully demonstrate the savings potential yet, but that could help start a discussion.
Beta Was this translation helpful? Give feedback.
All reactions