Experimental: Reduce ~3.5 KB via Build Improvement / Staying under 64 KB #49

Open
opened 4 months ago by trholding · 7 comments

It is possibe to bring down the size of the wiki by using the mangle props option of terser and figuring out reserved names.

This is what has been accomplished:

62683 FeatherWiki_Dove.js
59155 FeatherWiki_Dove_Tersed.js

66207 FeatherWiki_Dove.html
62680 FeatherWiki_Dove_Tersed.html

3527 Bytes Saved!

The following example is for the Dove version. For the PUT saver versions, more reserved names may need to be added.


$ terser FeatherWiki_Dove.js -c passes=2 -m --mangle-props reserved=[np,pell,icon,edits,content,editor,img,italic,actionbar,slug,root,edit,help,p,events,name,tags,parent,event,underline,strikethrough,heading1,heading2,paragraph,olist,ulist,image,out,hLink,pg,md,recent,query,changed,sb,sbTab,views,notis,wTitle,wDesc,wPub,wOut,wJs,wCss,wPo,home,desc,pages,\"\",_,\"\*\",\"~\",\"\\n\",\"\ \",\"-\"] > FeatherWiki_Dove_Tersed.js

Some of these reserved names maybe removed to make the wiki more smaller as I may have added things that don't affect.

How to optimize further or for future versions of wiki:

Optimize the above tersed version by looking at beautified (unminified) outputs of both FeatherWiki_Dove_Tersed.js and the following safely tersed one FeatherWiki_Dove_Tersed_Safe.js with visual diff tool like KDE kompare. Debug with the developer tools / browser console, if something breaks, add reserved words to -mangle props reserved array of terser.

$ terser FeatherWiki_Dove.js -c passes=2 -m  > FeatherWiki_Dove_Tersed_Safe.js

The results may need Q/A / Testing as extreme property mangling is prone to break stuff.

Things to explore:

  • Run terser before closure compiler
  • Run terser only
  • Compare both
It is possibe to bring down the size of the wiki by using the mangle props option of terser and figuring out reserved names. This is what has been accomplished: 62683 FeatherWiki_Dove.js **59155** FeatherWiki_Dove_Tersed.js 66207 FeatherWiki_Dove.html **62680** FeatherWiki_Dove_Tersed.html **3527 Bytes Saved!** The following example is for the Dove version. For the PUT saver versions, more reserved names may need to be added. ``` $ terser FeatherWiki_Dove.js -c passes=2 -m --mangle-props reserved=[np,pell,icon,edits,content,editor,img,italic,actionbar,slug,root,edit,help,p,events,name,tags,parent,event,underline,strikethrough,heading1,heading2,paragraph,olist,ulist,image,out,hLink,pg,md,recent,query,changed,sb,sbTab,views,notis,wTitle,wDesc,wPub,wOut,wJs,wCss,wPo,home,desc,pages,\"\",_,\"\*\",\"~\",\"\\n\",\"\ \",\"-\"] > FeatherWiki_Dove_Tersed.js ``` Some of these reserved names maybe removed to make the wiki more smaller as I may have added things that don't affect. How to optimize further or for future versions of wiki: Optimize the above tersed version by looking at beautified (unminified) outputs of both FeatherWiki_Dove_Tersed.js and the following safely tersed one FeatherWiki_Dove_Tersed_Safe.js with visual diff tool like KDE kompare. Debug with the developer tools / browser console, if something breaks, add reserved words to -mangle props reserved array of terser. ``` $ terser FeatherWiki_Dove.js -c passes=2 -m > FeatherWiki_Dove_Tersed_Safe.js ``` The results may need Q/A / Testing as extreme property mangling is prone to break stuff. Things to explore: * Run terser before closure compiler * Run terser only * Compare both
trholding added the
request
label 4 months ago
Owner

My first instinct is to be wary of mangling the object props because it can cause a lot of problems that you might not expect. Having the option for reserved prop names is good, but it would quickly become a pain to maintain... Plus with the changes I'm making to let extensions be more useful, there are a lot more props that would need to be reserved.

We can definitely play around with it, but it might be more trouble than it's worth.

My first instinct is to be wary of mangling the object props because it can cause a lot of problems that you might not expect. Having the option for reserved prop names is good, but it would quickly become a pain to maintain... Plus with the changes I'm making to let extensions be more useful, there are a lot more props that would need to be reserved. We can definitely play around with it, but it *might* be more trouble than it's worth.
Alamantus added the
enhancement
discussion
labels 4 months ago

Neither tersed or untersed will run in Opera, likely because it's still run through the Closure compiler either way. Firefox loads both just fine, but I haven't tried to actually use either.

Neither tersed or untersed will run in Opera, likely because it's still run through the Closure compiler either way. Firefox loads both just fine, but I haven't tried to actually use either.
Owner

I'm not sure what Opera's deal is... It always seems to have some kind of issue. But it's true that the more you compress and obfuscate the code, the more starts going wrong.

@nosycat are you able to create your own builds? I believe Firefox runs Feather Wiki fine, but I remember you needed a build without closure compiler run on it. If you are able to build it on your machine, I can show you what to comment out in the build script to skip the closure compiler step if you need help!

I'm not sure what Opera's deal is... It always seems to have some kind of issue. But it's true that the more you compress and obfuscate the code, the more starts going wrong. @nosycat are you able to create your own builds? I believe Firefox runs Feather Wiki fine, but I remember you needed a build without closure compiler run on it. If you are able to build it on your machine, I can show you what to comment out in the build script to skip the closure compiler step if you need help!

I can't create my own builds because I don't use Node. Never mind, thank you.

I can't create my own builds because I don't use Node. Never mind, thank you.
Poster

@nosycat Okay can you give me a TLDR of the opera issues, I'll experiment and check.

Also the tersed stuff above is experimental. Mangling is not worth it I guess.

@nosycat Okay can you give me a TLDR of the opera issues, I'll experiment and check. Also the tersed stuff above is experimental. Mangling is not worth it I guess.

@trholding See this Mastodon conversation for reference. Tl;dr version: it's the Closure compiler.

@trholding See [this Mastodon conversation](https://wandering.shop/web/statuses/108391435156992094) for reference. Tl;dr version: it's the Closure compiler.
Poster

@nosycat, I'll do thing, when I get time today I'll disable closure for me, then build stuff this way: #34 and send you the outputs here. Tersed output likely to work.

@nosycat, I'll do thing, when I get time today I'll disable closure for me, then build stuff this way: https://codeberg.org/Alamantus/FeatherWiki/issues/34 and send you the outputs here. Tersed output likely to work.
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Reference: Alamantus/FeatherWiki#49
Loading…
There is no content yet.