1
8 Comments

CDN or ZIP file?

Hi,

I'm preparing an update for www.loopple.com and I was wondering what you, as developers, would prefer. The downloaded file now is a simple index.html file with CDN links to Javascript, CSS, and images files. I was thinking of changing the download file to a ZIP that includes the index.html + assets folder.

on April 9, 2021
  1. 2

    Eventually offer both and let the user choose how he wants to download it.

    1. 1

      Thank you for your answer @pixtron!

  2. 1

    What CDN are you using? Many CDN’s, like AWS Cloudfront, offer the ability to zip automatically for you, so you as a developer really don’t have to think about this. Cloudfront offers gzip and Brotli compression options... You can use a CDN for your own assets, which will (optionally) zip the files for you before sending the zip to the users browser, and you can use the CDN resources for third-party assets. You get the best of both!

    My personal preference is to keep assets separate... Each project is different and has unique needs, so your use case may not see benefits from this approach, but in my experience there are some benefits to this approach:

    • Keeping them separate allows multiple async downloads of assets to happen at once; which is potentially faster for the user.
    • Keeping them separate allows for lazy loading; no point in sending assets that are never seen/requested... If a user never scrolls down your page, you’ve sent those assets (ie images, videos, etc) unnecessarily.
    • The user has to wait for that single large download to complete and unzip before they get the first paint; this may have some SEO implications
    • You can change and redeploy an individual file, without having to re-zip and redeploy all assets.
    • If you’re versioning individual files your users can keep using cached versions of unchanged files, and request only the updated files vs having to request the entire package including assets which may not have changed.
    • The previous point also saves you (and possibly your users) on bandwidth costs; it’s expensive and unnecessary to force users to download assets that haven’t changed when the change was only a single file that is only a small percentage of the overall package size.
    • Using the CDN resource of a third party asset can help make it easier to ensure your service always has the latest versions which may address security issues.
    1. 1

      Hi @hephalump and thank you for the answer, this is really helpful!

  3. 1

    Would it be possible to inline the JS and CSS so it is only x single index.html file?

    1. 1

      Hi @stephenafamo. It is possible but the CSS/js files have over 1000 lines of code and I think the index.html will have too much content.

      1. 2

        I don't think that is too much of a problem.

        Since it is a single page app, all of that will have to be downloaded anyway, but having it as a single file really simplifies the deployment.

        1. 1

          It sounds good and makes sense, thank you very much for help!