Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Safe minification recommendation

I am currently working on a rewrite for my Mythras sheet and this time around I was hoping to minify it.  I have already run into two issues caused by the minification process, one of which I'm still trying to figure out. Can anyone recommend an html minifier which seems to work well for them, or point out things that may potentially cause issues.  I have already disabled the removal of quotes around attributes because removing the double quotes from text/worker caused sheet workers to fail.  I'm currently using nodejs-html-minifier with the following config: { "caseSensitive" : false, "collapseBooleanAttributes" : true, "collapseInlineTagWhitespace" : false, "collapseWhitespace" : true, "conservativeCollapse" : false, "decodeEntities" : true, "html5" : true, "includeAutoGeneratedTags" : false, "keepClosingSlash" : false, "minifyCSS" : true, "minifyJS" : false, "preserveLineBreaks" : false, "preventAttributesEscaping" : false, "processConditionalComments" : true, "processScripts" : [], "removeAttributeQuotes" : false, "removeComments" : true, "removeEmptyAttributes" : true, "removeEmptyElements" : false, "removeOptionalTags" : true, "removeRedundantAttributes" : true, "removeScriptTypeAttributes" : true, "removeStyleLinkTypeAttributes" : true, "removeTagWhitespace" : false, "sortAttributes" : false, "sortClassName" : false, "trimCustomFragments" : true, "useShortDoctype" : true }
1574385083
GiGs
Pro
Sheet Author
API Scripter
Is there a reason you want to minify it? The difference it'll make to performance is marginal at best, and it'll make it harder for other people to contribute to it or more importantly, take over the sheet if you are ever unable to keep maintaining it.
1574386705

Edited 1574387379
Matt Carpenter
Pro
Sheet Author
A few reasons: 1) Because I just wanted to learn about using minification. Before working on Roll20 sheets I haven't done a lot of front-end web development.  Since then I have taken some of what I learned to my professional life and visa versa.  So I try to use my Roll20 development as a way to learn and in this case I wanted to try out minification and work my way through those inevitable pitfalls. 2) General sense of being a good Roll20 citizen.  I'm sure they won't mind if I can save them some bandwidth. 3) The sheet has grown quite large(1.5MB) and some users have started to mention performance issues.  This is partly why I'm going back and doing a full re-write.  Now that I have a little more experience I'm sure there are things I can do better and I'm trying to kept an eye on optimization while I'm at it.  I'm sure the minification will be small compared to some of the general design and sheet worker changes I'm making, but it's something. As for making contributions harder, I intend to keep the pre minified sources in the git repo.  I have recently started using a whole build system with various sections of the sheet broken up into smaller files which is also in the repo.  Hopefully that will actually make it easier for people to get involved and navigate the sources.
Also in case anyone else runs into this minification issue.  I had to set removeRedundantAttributes to false.  That was the source of my 2nd issue.  It was stripping type="text" from my text inputs.  That caused the sheet to not save user input in any text inputs.
1574389950
GiGs
Pro
Sheet Author
API Scripter
I had a look over your sheet workers section, and i can suggest quite a few areas to at least reduce the line count there, and also improve performance in various areas. Would you like me to message you with suggestions, or do you prefer to do it all yourself?
GiGs said: I had a look over your sheet workers section, and i can suggest quite a few areas to at least reduce the line count there, and also improve performance in various areas. Would you like me to message you with suggestions, or do you prefer to do it all yourself? Sure thing, thanks.