5
21 Comments

Page loading time 19 times faster!

I want to share with you all some pretty amazing achievement! I am not sure how tech-savvy you all are, but nonetheless I am going to do it πŸ™‚

Today we figured out a way to made our pages load 19 times faster than before. We had dependency loader that used to bundle all files into one, but the bundles were slightly different on different pages.. So the same files needed to be loaded each time on every page.

Now we tweaked the dependency loader to simply load the minified files as individual scripts... and the browser takes care of caching... so same files on different pages get served from cache.. 0ms load time!!!

Page load time went from 14s to ~730ms πŸ™ŒπŸ™ŒπŸ™Œ

Some additional context:

When building the application we refrained from using any existing JS bundlers such as webpack, or requireJS, etc... and developed out custom dependency loader ( piggybacked the idea from how grails does resource loading ). Long story short, while watching a demo video of a customer we noticed that pages were loading slowly, averaging about 3-4 secs.. and that started worrying us. So we started digging in and noticed that bundling all the JS into one file ( ~24MB ) was making the browser download such a large file. Another caveat to our original approach was that all the dependency hierarchy was generated by a server-side language ( in our case ColdFusion but this goes for any language... ) and some recent Chrome changes made the browser NOT to cache the script if the script did not have a .js extension. In our case it was

<script src="/inc/scache_js.cfm"></script>

and that made the file being loaded anew every single time =(

We are still using the same dependency loader but instead of combining all the JS into one file we load each script ( minified ) as a separate script. That made it cache instantly and the performance on a simulated 3G connection went from 30s to 3s. Unthrottled the pages load now in ~730ms.

on December 23, 2021
  1. 3

    God damn, 14s initial load time? How was it let to devolve into that? I can't imagine it just jumped from 1-2s to 14s after a single update XD

    1. 1

      No, we always had the loading issue we just never noticed it. Fyi, I have updated the original post with the more detailed answer =)

  2. 1

    How long should a SaaS dashboard take to load? is nine sec acceptable for my software product https://twayobiz.com?

    1. 2

      So the rule of thumb is the resources ( JS, CSS, images, etc.. ) should not exceed 1s load time. The subsequent data server calls can take longer but it would be advisable to show some type of spinner to show loading.

      1. 1

        I do show a spinner in the dashboard actually. Its only in the dashboard though meaning you have to have signed up to understand what I'm talking about as far as my loading spinner goes.

      2. 1

        This comment was deleted 5 years ago

  3. 1

    Incredible achievement.

    14s is one HELL of a load time so getting that down to under 1s is certainly going to reap a lot of benefits.

    Any further breakdown on what you trimmed and how?

    Have you used web.dev to see the full metrics?

    1. 1

      Thank you!, I have updated the original post with the more detailed answer =)

      1. 1

        Cheers Linda!

        Are you able to share the page? It would be great to see it in action.

        I imagine the client is super happy! 🍾

        1. 1

          Yes of course! For instance, here is our Roadmap board that we made public -- https://cogency.cogency.io/proxy/bvr -- this was taking around 15s to load!

  4. 1

    Congrats for achieving this, I can imagine it must be a huge satisfaction to see this improvement.

    1. 1

      Thank you!!! I have updated the original post with the more detailed answer =)

  5. 1

    Performance optimisation can often feel like whack a mole until you find one big issue. Great work!

    1. 1

      Thank you! I have updated the original post with the more detailed answer =)

    2. 0

      Thank you! I have fiber connection so never noticed any slowness, but did see a demo made by a customer where they waited for a page to load for a few secs.. and that worried me! I have updated the original post with the more detailed answer =)

  6. 1

    Sometimes the simplest things like leveraging server/browser caching as you did can have the most profound unexpected results. Congrats!

    1. 1

      Yeah its weird b/c best practices dictate to as less files as possible due to server requests that are made for each script.. however, in this particular case it seems the decoupling did help a lot!

      1. 1

        After seeing the additional info, I have a couple suggestions.

        First off, most any modern web server should have some kind of way to handle aliases that will let you serve the files as .js instead of _js.cfm. That will leverage browser caching.

        Second, I know you said you load up different things on different pages, and that can be ok, but there are surely some of them that are common and can be bundled into a common.js file or something then the page-specific can be sent as necessary. Ideally, you'd build custom per-page bundles as well so you're only serving two JS files -- common.js and this-page.js.

        Hope it helps streamline things further.

        PS: I didn't know ColdFusion was still a thing. 😎

        1. 2

          This is an awesome comment!!! Thank you!
          I think you are onto something here with aliasing. Now that I think about it, I believe we could have leveraged our nginx proxy to serve files as .js. Very awesome thought!

          =)

  7. 2

    This comment was deleted 4 years ago

    1. 1

      LOL, yeah that what i want to know too!! We have fiber in the office and I guess this has never been an issue until we saw a client's demo video!!

      I have updated the original post with the more detailed answer =)

  8. 1

    This comment was deleted 3 years ago

    1. 1

      We used straight up browser dev tools ( network tab ) to measure the download speed. Also reached out to some of our customers to see if the pages were loading faster for that.. BIG TIME improvement =)

      1. 1

        This comment was deleted 3 years ago

        1. 2

          We did both. Obviously loading minified files in prod sped things up even more =)

          1. 1

            This comment was deleted 3 years ago