Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Hareesun

I don't suppose some better baking options might be possible? As at the moment it basically just obscures it without actually minifying much. Would be swell if so. :)

1 decade ago by dominic

Usually, minifying JavaScript code isn't all that effective. The JSMin minifyer that is used in the baking script just removes whitespace. Google's closure compiler also shortens variable names etc. That might give you another 10-30% smaller filesize.

The main purpose of the baking script is not to shrink the filesize, but to combine all source files into one big file. This already cuts the loading time immensely, because every single HTTP request has some overhead, so limiting the number of requests is often more important than the size of the files.

If you still want to shrink the filesize, configure your webserver to send your .js files gzipped.

Here's an example: the Biolab Disaster source was 248kb before baking and 219kb afterwards. Google's closure compiler is able to shrink it further to 186kb (I didn't bother with that). However if you look at the size of the source (Right-Click -> View Page Info in Firefox), you will see that is only 46kb because it has been sent gzipped.

A basic .htaccess file for Apache that will enable gzip compression on .js, .css and .html files (provided that mod_deflate is available) looks like this:
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/x-javascript text/css text/html
</IfModule>

1 decade ago by Hareesun

Dom, you're a genius. I completely forgot about the gzipping possibilities. Thanks for the reminder! :)

1 decade ago by RobLuk

I'd like to run my game.min.js through the Google Closure Compiler. However, when I tried this, I get JSC_TRAILING_COMMA error due to a trailing comma in an array in lib/impact/system.js

The error message states: "If you are targeting newer versions of JS, set the appropriate language_in option."

I searched for documentation on 'language_in', but so far I have been unsuccessful. Does anyone know the correct 'language_in' setting to target the newer versions of JS (which I believe will work with any browser that supports canvas).

Thanks in advance.

1 decade ago by Akis

I use Google Closure Compiler and it works fine, with small changes in the engine though. I will probably give write a post with my tools this weekend (just need to clear some stuff in my files).

For the error you mention, it's the comma at the end of an object definition. like this:

var obj = {
   prop: 1,
   prop: 2,
};

We should never have a comma after the last property (prop: 2).

For me, it's important to have a better baking system, because anyone can steal the engine right now, and every games in the Games section of this forum actually.

1 decade ago by RobLuk

Yeah, I was able to play with this more and figure it out. 2 of the Engine files had the trailing comma. Works great now.

8 years ago by tonytong198

you can try this free online service to minify javascript and minify css, so it will reduce the size of web page.

8 years ago by stahlmanDesign

I use impact-node with Impact games instead of Dominic's default setup. It allows you to use Weltmeister without *AMP / PHP and the bake command makes smaller files than Dominic's script. The author responded to some of the issues I brought up and it's pretty cool if you are into Node.js.
Page 1 of 1
« first « previous next › last »