Skip to content

Include minification and compress process in repo #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Lukenickerson opened this issue Apr 26, 2024 · 4 comments
Open

Include minification and compress process in repo #27

Lukenickerson opened this issue Apr 26, 2024 · 4 comments

Comments

@Lukenickerson
Copy link
Contributor

Continuing the discussion from #22 (comment) ... It would be good to have the compression process in the repo, so that any changes could compare the minified/zipped size. As a micro framework we don't want the size to get much bigger. This should be a blocking issue to do before other changes so that we can monitor the size changes.

Suggestions: terser, ect.

Other ideas: https://github.com/morph-games/ring-rescue/blob/main/steamroll.mjs

@Lukenickerson
Copy link
Contributor Author

Lukenickerson commented Apr 26, 2024

I've tried running a slightly modified w.js (manually compressing the shader strings) through terser, google closure compiler, and uglify-js, and the best I can get it down to is 8,844 (from terser), compared with 8,610 bytes in w.min.full.js.

But combining Uglify or Terser + Roadroller it goes down to somewhere in the range of 3,850-3875 bytes. @xem -- Do you consider this good?

Example of roadroller output:

eval(Function("[M='AEP?CvzTZzzZt|P~]|iP|mIVq`E�~Dj[OBtU]am�tms_WbJ}]khs?zqAbSefvYnFyfMC@r]QH{P{hI?YT]eHrLHnY?|rzsBG}cew]SI`JzNDpbORrFS?_}gFwHZreRjteoUtFY^Fhoq^|WVVXtG{ly_M_}puK[Dh@z||{JVUotNgC]oTQ[ZtsUmvAAs{t�sy|rs~I]`uTpbzeOtjmSpyKj{OrGuBDms{PhCHp{s@AAUFNUx}nYt_[}aQG?^AFJx[bdtmFPbE@iCpnBaVRI~GQecGEt_pHx|FfL}^{TWGamdiBjAvMa�dUvZ?ysWA@sfzZEgLxcGpHpvreUyGHYAGLQhNy|A{^|s[alGoXaD?N{A]y@aO_c}PKJE�LoEelisqP}Nk@UpYGbmIRvgSvQEAy{buQdC|kFUDMNP[?j@Oued@`}AHWKOYbV_NatbF[WruNWOkw{wx@hLCslUE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nEeQc@XEIlc|APqJMsIWI�ixYG�]CkhgpMhUEkbIuYgsxJVThbRigBo_mHXs~MUN�I^U^cQ�oY?LECAT@S}dx}WtkZ`�XG?~aTaIjU@lNVFTiRQ@HjRCyNaDarpVYz�G_uVchXBK?o[{M`olWuIpOzWegStguk}?HnMSSEABNhqrim|t@Xuh{B}Wo[`fPtniKU|SXjIWEJD{X{DV~uPJW^Gvh_fACw_j[D~JdanR�s�Ui]OITuduk[K`BnWDPVB[T[mVSHNNYzki?ILOP{kr�jtkTHeJF]?vcWiT|ayNsweei}[]qY??yVay{XHK{oOFy[FhMN|il_JNmlRVnxwI{wlVMzPRuRHelOo{tkw?mHwNHyyD`osTahPko|]NYZUvsaSX`l_nMXxCUEjCu[njB@PUzozUyr�_LtDUqM@~R[~zm|yil_sFRaIqsnPY~sYJguM__Sa`~hV^^s~sp[Cmr_VTWGfyjsemYFQIb@}fBV_jHbOGobK`v^jOJw`QVQVv{o^qRkn^QDqlgSYgmXDyWyJMrc^Z|o_fB{KUIe[L]MPMGLF`YyA{VSyf�DBTO|pIacwD[SM�?KZ}[VRunl]BFP`fa|FhxozSdzwoPxAutSoo?s{X]eboP~OT@Aeccuwo`E]P{uzQw�jgzbjxY'",...']charCodeAtUinyxp',"for(;e<8844;c[e++]=x-128)for(x=1;x<128;n=p.map((i,y)=>(t=r[i]*2+1,t=Math.log(t/(h-t)),A-=a[y]*t,t/750)),A=~-h/(1+Math.exp(A))|1,U=o%h<A,o=o%h+(U?A:h-A)*(o>>15)-!U*A,p.map((i,y)=>(t=r[i]+=(U*h/2-r[i]<<15)/((C[i]+=C[i]<5)+1/20)>>15,a[y]+=n[y]*(U-A/h))),x=x*2+U)for(p='0102021032032104204310531065410976432098762'.split(A=0).map((i,y)=>(t=0,[...i].map((i,y)=>(t=t*997+(c[e-i]|0)|0)),h*128-1&t*997+x)*12+y);o<h*128;o=o*64|M.charCodeAt(d++)&63);return String.fromCharCode(...c)")([],[],1<<15,[0,0,0,0,0,0,0,0,0,0,0,0],new Uint16Array(51e6).fill(1<<13),new Uint8Array(51e6),0,0,0))

Edit: Of course, once I zip the road-rolled code, it is still not as small as your w.min.full.zip. I don't know what magic you used to compress everything!

@xem
Copy link
Owner

xem commented Apr 26, 2024

Hi! did you release a game for gamedevjs? can't wait to try it! (here's mine: https://maximeeuziere.itch.io/the-power-of-two)

As for compression, I confirm that W.js has always been compressed manually with Terser, through https://try.terser.org/ ... or my tool that has a few optimiztions built-in: https://xem.github.io/terser-online/

RoadRoller's footprint is quite big, and for small files like W.js, it's generally less efficient to do (Minify + RoadRoller + Zip) than (Minify + Zip) alone. But it's worth double-checking!

However, when W.js is used in a js13k entry, in that case, roadroller is very good at compressing the entire JS codebase of the game. Roadrolling W.js alone is a bit less meaningful as you can imagine.

Anyway, feel free to push a PR with your edited W.js and I'll see how well I can minify it on my side!

@xem
Copy link
Owner

xem commented Apr 26, 2024

Oh, your entry is Puck it up? Wow! I have no idea how to even start making a game that looks this good.

@Lukenickerson
Copy link
Contributor Author

Yeah, I did Gamedev.js too -- mine is https://deathray.itch.io/ring-rescue -- made with W. I'll check your game out.

I found that uglify + zip turned out to be smaller than roadroller or any other combination. I'll have to check out the manual compression with Terser to see what can be done, and in the meantime send over the other code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants