Ethics / convention - compressed code

Posted on
  • Hi there, I developed a small simple app, and wanted to add it to the BangleApps repo.
    It is about 8.2kb (+ 0.5kb icon), but using a js minifier I can get it down to 3.4kb, at the expense of readability of course.
    Also anyone who wants to check that the minified code hasn't been modified would have to use a similar minifier, and it could seem a bit dodgy / frustrating.
    If I include the original source alongside the compressed version, is that still OK, or is it not worth the hassle for the sake of 5kb?
    Thanks for any ideas, or suggestions on a better place to ask.

  • Hi!

    Just so we're on the same page, do you know of the pretokenisation and minification options on the App Loader "More..." tab? (note especially the wording regarding minification on upload, under "Advanced Options")

    Also anyone who wants to check that the minified code hasn't been modified would have to use a similar minifier, and it could seem a bit dodgy / frustrating.

    If you're not already, maybe you could choose to use the same minifier that the App Loader uses, making reproducibility easy for a user who wants to verify the code.

    If I include the original source alongside the compressed version, is that still OK, or is it not worth the hassle for the sake of 5kb?

    There are examples of apps keeping both the minified and the non-minified code in the repo, choosing to upload just the minified to the watch. But more often only the non-minified code is stored on the repo.

    Historically, it's happened that minified code wasn't updated when the non-minified code was changed. So it looked like the app was updated, but functionally on the watch it wasn't. Presumably we'll be more observant of this going forward though.

    Looking forward to seeing the app! When you're ready to submit the PR specifics can be worked out there :)

  • I think it's important to consider what happens when someone else wants/needs¹ to modify your code: just having to worry about minification is a hassle, but if really necessary it should at least be reproducible: that way somebody can check they got the minification right before even making changes, so they know any (new) bugs aren't caused by getting the minification wrong.

    ¹. It doesn't happen often anymore, but sometimes e.g. library code needs a fix that also requires all the apps using it to be updated.

  • Thanks for your inputs, I admit I didn't realise the App Loader already had a minifier! I think I'll leave the source code unminified, since I agree that it's tricky to get reproducable minification, especially if it completely changes the variable names.

  • I think it's best to leave code unminified as you say. Pretokenisation is on by default is effectively a very simple minification anyway.

    Sometimes it does make sense to minify - for instance you may have some code that needs to run as fast as it possibly can (or to be very small on the watch) - and then of course having minified code on the device can be good.

    But unless you really do need that, I'd just leave the code as-is. Often the speed difference is very minimal, and it's not worth the hassle of maintaining the minified code.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Ethics / convention - compressed code

Posted by Avatar for Biran4454 @Biran4454

Actions