B4J Question [BANano]: BANano.GZipGeneratedWebsite() after Post Processor?

Discussion in 'B4J Questions' started by Mashiane, May 22, 2019.

  1. Mashiane

    Mashiane Expert Licensed User


    I'm running a post processing script based on Kiffi's post processor

    My challenge is that when running my site against website profilers, they recommend that I use gzip for the resources. This means the images, css and js files need to be gzipped for better performance of the website.

    The GzipGeneratedWebsite I assume works before any post processing takes place. Is it possible to have this feature to be activated after any post processing is done?


    My app is recorded as having a lot of css and js files in it. Granted. This includes all the css and js files from my BANano based lib that I use for creating my BANano based apps.

    After BANano.Build, my post processor ensures that ONLY the css and js files that are used by my project are included in my project and all other ones are removed from the final build. These css files are consolidated into 1 single css and this is the only one added on BANano.Header before the post processing.

    The catch though is, if .UseServiceWorker is turned on, all the css and js files added on the Files tab are included. This is irrespective of the post process exercise.

    The js files so far are rather tricky as some just break my code if merged into a single file, so I only leave these for compression by the post processor.

    So, without having to be manually removing files from the files tab (directly from my banano library), I need to have a way to post process the service worker file css and js list, post process gzip resources etc etc. Phew!

    Last edited: May 22, 2019
    joulongleu likes this.
  2. OliverA

    OliverA Expert Licensed User

    I'm pretty sure GZipping(?) is a task for the web server hosting your site. Also, the only way to properly reduce JPG output size is via changing the size of the image, changing the quality of the image or reducing colors used in the image. Compressing JPG files again (via GZip) may be counter productive, increasing the size of the generated file.

    inakigarm and Mashiane like this.
  3. Mashiane

    Mashiane Expert Licensed User

    @OliverA your comments are noted, thanks, BANano.GZipGeneratedWebsite generates these .gz files for each of the resources on your project for css and js files so that the server has them for the needed exchanges.

    All of this happens as soon as your resources are copied from the files tab to the build folder of your project but before the post processor.
  4. OliverA

    OliverA Expert Licensed User

    I guess I'm asking why the .gz files are generated beforehand, since it has always been my experience/observation/limited knowledge that the web server does this for you. Quote:
    Source: https://css-tricks.com/the-difference-between-minification-and-gzipping/
    If something has changed and you/someone else can provide some information on pre-gzipping files for the server and the benefits, then please do so.
  5. alwaysbusy

    alwaysbusy Expert Licensed User

    @OliverA You are right. It is something I took over from ABM where, way back in the day, jServer couldn't do gzipping yet and doing it manual somehow worked (or at least the site speed tools where somehow fooled, I can't really recall). I just tested it with a BANano site from a client (where gzipping is not enabled on the server site) and it doesn't make any difference (although I could swear in the far past when I've build it in ABM, it somehow did)

    But getting old and memory and stuff, you know... :D
    Last edited: May 23, 2019
  6. alwaysbusy

    alwaysbusy Expert Licensed User

    Nginx had also something to do with it I remember:

    It is possible to manually compress certain files using gzip.

    Nginx can use this when you set gzip_static to ‘on’.
    When this setting is enabled, when requesting a file, Nginx will look for .gz and if this one is nonexistent, serve the non-compressed file otherwise.
    Mashiane likes this.
  7. OliverA

    OliverA Expert Licensed User

    Thanks! Looks like I learned something new. I can see such a setting for Nginx, since it tries to be light an limber, whereas something like Apache is like having everything, including kitchen sink. One of the reasons (in the past) to let the server handle the compression is that it will compress all files that it can (html, txt, etc.), leaving that burden to the server instead of the developer. Some (this is from the top of my head) servers skip compressing files such as JPG files due to the negligible (or even worse) outcome of the compression on these files (either out of box or through configuration).
    Mashiane and alwaysbusy like this.
  8. Mashiane

    Mashiane Expert Licensed User

    Me too hey... i'm so self taught with this programming stuff its not even funny. Thanks to both of you.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice