Open unit-404 opened 4 days ago
I guess we can try using URL encoded instead of base64 like mini-svg-data-uri
does. It should reduce the length if the code mainly includes ASCII characters.
Regarding using the compression API, I don't think that would actually reduce the code size. In most cases, the code would be served as gzip or other compressed format, so it won't affect the size sent over the network.
I guess we can try using URL encoded instead of base64 like
mini-svg-data-uri
does. It should reduce the length if the code mainly includes ASCII characters.Regarding using the compression API, I don't think that would actually reduce the code size. In most cases, the code would be served as gzip or other compressed format, so it won't affect the size sent over the network.
I would to have single-file library with embedded web worker. Also, input language is TypeScript with some TS modules (which will baked), so I can't just simply encode like SVG assets. So I today try to modify Vite itself. Isn't enough to just encode to base64, needs to pre-compress compiled web worker code.
Update: I tried to do such trick, got 24kB of minified code. Interesting what happen if embed just worker code and compress to GZIP fully (me feels like from 4 to 8 kB of gzipped), but (I think) not all JS module loaders will supports full compressions (i.e. whole module). Before was 40kB.
so I can't just simply encode like SVG assets.
I was suggesting changing Vite's behavior, not doing it on the user land.
Isn't enough to just encode to base64, needs to pre-compress compiled web worker code.
What do you mean by pre-compress?
but (I think) not all JS module loaders will supports full compressions
Effectively all browsers support gzip compressed contents. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding#browser_compatibility
Description
I want to getting smaller inline code of Web Worker, uses another than Base64 encoding, or using compression API. I want to have API to code transform control.
Suggested solution
import WorkerCode from "./Worker.ts?worker&inline-compressed"
Alternative
No response
Additional context
In general, I currently getting big code of library (for example,
64kB(now 40kB) minified in base case). But just base64 encoding isn't always best solution, I want to reduce library size even more (at least 20kB or lower).Validations