Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #13335.
This minifies the WebGL shaders, mostly by removing comments and unnecessary whitespace. Example of shader before minifying:
and after:
Bundle sizes on
branch-3.4
:and after this PR:
so it saves 17.8 KB of the
gl-min
bundles, about 8.7%.I looked at existing NPM packages for this and didn't find any I liked. Mostly they are unmaintained and tightly coupled to webpack. So I wrote my own as a sequence of regex replacements. These should by understandable by anyone (including my future self) with some regex knowledge. The multiple passes of each shader, one per regex, are probably not very quick but GLSL is such a small fraction of the BokehJS codebase that there isn't any measurable increase in build time on my dev machine.
In future we could extend the minifying to replace local function and variable names with smaller strings, but that would require storing state so would need a different implementation.
Testing is a problem. I think that the visual baseline tests use the unminified bundles so this will not be tested by CI. Could you confirm this @mattpap?