Minifier Extension [0.1]

yoplalala

  • *
  • Posts: 1491
This is a simple extension;   to use dce  (dead code elimination) https://haxe.org/manual/cr-dce.html
The problem was if you put the haxe flag dce --full,  all scenes and behaviors were removed.
This extension will keep all code in the package script by adding the @:keep metatag and you don't even need to put the haxe flag !

Blank Game

Flash
Without dce :  807.5 k
With dce       :  506.4k

Linux
Without dce :  26.8M
With dce       :  17.2M

My Game
Without dce :  43.1M
With dce       :  33   M

If it says it cannot compile the game because  of X class.

Just put after the imports
@:keep

If something in Stencyl  classes don't work ( and not some random extension or your code), you can post here, and I 'll modify the extension.

« Last Edit: October 13, 2018, 08:15:28 am by yoplalala »

mdotedot

  • *
  • Posts: 1512
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!

Hanging out in the Chat:  http://www.stencyl.com/chat/

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

yoplalala

  • *
  • Posts: 1491
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: 1512
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.
Hanging out in the Chat:  http://www.stencyl.com/chat/

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

yoplalala

  • *
  • Posts: 1491
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: 1512
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 »
Hanging out in the Chat:  http://www.stencyl.com/chat/

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

colburt187

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

mdotedot

  • *
  • Posts: 1512
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!!!
Hanging out in the Chat:  http://www.stencyl.com/chat/

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

RulezTeam

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

RulezTeam

  • *
  • Posts: 296
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: 296
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: 1491
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: 296
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