Minifier Extension [1.1]

yoplalala

  • *
  • Posts: 1632

Minifier DCE Extension

This extension is a convenience extension for Stencyl users, it just adds specific flags, which enables DCE, Dead Code Elimination.

It removes unused code, which saves place.

Doesn't work well for html5.

Tested on Stencyl 10500

Example

|                                        |                                         | Without DCE | With DCE   |
| ----------------          | ----------------             | -----------          | ----------        |
| Blank Game            | Flash                             | 807k                  | 506k               |
| Blank Game            | Linux                             | 28.5 Mo           | 16,7 Mo        |
| Real Life Game 1 | Linux                             | 43 Mo               | 33 Mo             |
| Real Life Game 2 | Android                       | 59.482 KB     | 57.689 KB    |
| Real Life Game 2 | Windows( zipped) | 132.646 KB  | 131.270 KB |
| Real Life Game 2 | Mac                                | 37.3 Mo          | 32 Mo             |
| Real Life Game 2 | iOS Simulator          | 21Mo               | 16 Mo             |


Where can I know more about DCE ?

https://haxe.org/manual/cr-dce.html


It doesn't compile after activating the extension ...
It has removed too much code.

If it because of your own code, you can put  after the imports

@:keep

You can add also haxe flags

```
--macro keep('type dot path')
```

If it is a normal Stencyl game without extensions, don't hesitate to contact me, I'll adapt the extension for you.


And what about html5 ?


You can upload the file  of your game, for example BlankGame.js to

https://jscompress.com/



For a 3mb blank game, you can have 46.43% compression, saving 1354.9 kb  .






Now on gitlab

https://gitlab.com/haxe-stencyl/stencyl-minifier

« Last Edit: April 01, 2021, 12:31:59 pm by yoplalala »

mdotedot

  • Posts: 1654
Hey Yoplalala,

This sounds interesting but I'm at a loss how to use it.

The block that comes with the extension has the ' print ' block in it which doesn't call the Minifier.addKeeps().
And when I try to use that Minifier.addKeeps() in a code block it says it cannot find it. (Propably due to the #if macro)

What Stencyl version does this work on?
What do we do to get it to work?
Does it has to be in the first scene when created event?

Settings : Settings : Advanced : Haxe Flags
Shouldn't it be -dce full  instead of dce --full ?!?

Again: I'm confused!

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

yoplalala

  • *
  • Posts: 1632
Sorry for the print ;) forgot to remove it :).
It works perfectly for me on Stencyl 3.5 without doing anything. I will test it on 3.4
You don't need to put code blocks, and you don't need to put haxe flags . You don't need to do anything.
The secret resides in include.xml ;)

mdotedot

  • Posts: 1654
Hmm ok, well the numbers aren't promising to m.e.

I've tried a couple of games on both Flash and HTML5 they didn't made much difference.
Flash Original  5723KB Minified 4928KB
Flash Original 124.472KB Minified 124.124KB
Flash Original 50.713KB Minified 50424KB
HTML5 Zip Original  51.278KB Minified50.877KB
HTML5 Zip Original  124.777 KB Minified 124.877 KB

The HTML5 on the larger one increased in size !!!!

I tried 3.5 version 10014 and an earlier version 9897 which didn't make much of a difference.

Also to be sure I did a Clean Project before each build.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

yoplalala

  • *
  • Posts: 1632
Lol for the html one.
For html5, better maybe not to use it
Seems to save a few hundred kos for flash.
And 10 Megas for cpp .
Haven't tested for android and ios but it's also cpp so it must reduce the about the same.
Could be quite useful for this purpose if you need to put your game on  google play, etc

mdotedot

  • Posts: 1654
OK on the Android it made a significant difference.

Original         : 59.482 KB
With minify: 57.689 KB

Not much on Windows (Zipped)

Original        : 132.646KB
With minify: 131.270KB

A lot of savings on MAC:

Original     : 37.3MB
Minified    : 32 MB

Also profit on iOS Simulator:

Original   : 21MB
Minified :  16MB


« Last Edit: October 14, 2018, 01:11:06 am by mdotedot »
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

colburt187

  • *
  • Posts: 2416
This sounds interesting, so it could reduce the size of an iOS app?

mdotedot

  • Posts: 1654
It made a great difference on iOS Simulator so I guess it would also on a 'real' app.

Just enable the Minifier extension and publish a testversion ... Like Yoplalala said: that is all that it takes

Love to hear the results!!!
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

RulezTeam

  • *
  • Posts: 318
Thank you Yoplalala. I'll test it and report my result here as soon as I can

RulezTeam

  • *
  • Posts: 318
Hi Yoplalala,
I have some info for your extension; all my tests were made for Android. So these are my results :


- on 10024 no problem
- on 9928 games doesn't lunch (on smartphone and bluestack)
- File path error : on 10024 I have this this dialog error (show attachment)


Thank you

RulezTeam

  • *
  • Posts: 318
Other strange things :
If I've already compiled my app without your extension I can see an optimization on the dimension (from 16,651KB to 14.916KB), but If I recompile it from zero and I enable your extension, the final dimension is the same as the first one (16,654KB), so no optimization. Is this right ?

yoplalala

  • *
  • Posts: 1632
Oh, do you have the logs for 9928 ? (

Quote
If I've already compiled my app without your extension I can see an optimization on the dimension (from 16,651KB to 14.916KB), but If I recompile it from zero and I enable your extension, the final dimension is the same as the first one (16,654KB), so no optimization. Is this right ?
Not sure if I understand well,  but you must enable the extension _then_  compile it.

RulezTeam

  • *
  • Posts: 318
Hi yoplalala,
excuse for my bad explanation. I try to tell you what I've done.

a ) App never compiled  :
- disable your extension : 16.645 KB
- enable your extension (after already compiled) : 14.916 KB

b ) App never compiled :
- enable your extension : 16.651 KB

As you can see, if I compiled my app and then I enable your extension, I have a good result. But if I enable your extension and then I compiled my app for the first time, the result is like as I haven't enable it.  Is this right ?

Moreover, can you see the error for the long name/path that stop compiling app, if I enable your extension ?

For log in 9928, I'll try to recompile it and post asap.

Thank you

yoplalala

  • *
  • Posts: 1632
Up because it has been updated.