How to deal with filesize
- dead-code elimination
- YUI compressor: A mature minifier achieving good results, without changing the public API.
- Google Closure compiler: Much more than just a minifier, very aggressive algorithm, some versions of Haxe may not be compatible with the compiler.
- JSMin: A native Haxe port of JsMin - has the advantage of being pure Haxe code. Easiest to install (haxelib install jsmin) and run (haxelib run jsmin input.js output.js).
It's recommended to get accustomed to one of these and add the appropriate command to your build.hxml file responsible for production deployments.
-main Main -lib jeash --remap flash:jeash -js main.js -cmd haxelib run jsmin main.js main_min.js
Transparent compression is available on all client browsers supported by jeash, so it makes sense to use it. Unfortunately, you will need to configure your HTTP server to compress files while they are transmitted.
You will need to amend the following to your httpd.conf:
Whereby the path to mod_deflate.so is specific to your server filesystem layout. You will need to restart apache to adobt the new configuration, using your distribution provided init script (in most cases /etc/init.d/apache*) Most linux distributions (ubuntu, gentoo, etc) have a more sophisticated mechanism for their apache configuration, it's a good idea to become more familiar with this aspect from a distribution perspective.
If all is lost, it's best to check the official documentation: Apache deflate.
Nginx is a popular server, deflate is normally active by default. If not, the following configuration should be present in your nginx config, normally nginx.conf in /etc/nginx:
gzip on; gzip_min_length 1100; gzip_buffers 4 8k; gzip_types text/plain;
As with apache, you will need to restart nginx to adobt the new configuration.
You can check if compression works using wget:
The progress meter will tell you the final filesize.
Please contribute other server configurations if you find them. Thanks!
-main Main -lib jeash --remap flash:jeash -js main.js --dead-code-elimination
Warning: some other libraries are not compatible with this command-line option, if you get strange compiler errors, then it's best to turn this off. Jeash itself is known to work with this option though.
It's possible to achieve great gains, most jeash projects should land under 50kB, if all these steps are successful.