gfx / universal-zopfli-js

JavaScript binding to Zopfli with WebAssembly.
https://www.npmjs.com/package/@gfx/zopfli
Other
81 stars 3 forks source link

Possible to get this to work in browsers? #12

Open markusenglund opened 5 years ago

markusenglund commented 5 years ago

Hey,

I'm looking to get zopfli to work in a browser environment. I played around a little bit with the makefile in this project, but couldn't get it to work since I'm pretty new to web assembly. Have you tried to make a browser friendly build? Is it possible to do? (I'm not necessarily saying you should include it in the package)

Cheers

gfx commented 5 years ago

I think it works on browsers if they have WebAssembly support, although I have not yet tried it.

Will add tests on browsers later, but you can give it a try with webpack or something.

EvanHahn commented 2 years ago

I was able to get this working in the browser, but not with my bundler. This was because libzopfli.js didn't export itself when ENVIRONMENT_IS_WEB is true.

I patched this in the project I was working on, but I'm sure there's a cleaner way.