[Support Guide] Does Netlify optimize every single asset my site uses?

Last reviewed by Netlify Support: June 12, 2022

Actually, no. It doesn’t necessarily optimize every file of your site, but it does optimize certain file types as explained below.

Asset optimization is a complex topic. (More information can be found on the Netlify blog, here and here.) To summarize, “asset optimization” involves minifying (compressing) and merging assets (JavaScript, CSS, images) to improve the time it takes to download and display the content on a webpage.

What gets optimized with Netlify’s asset optimization?

  • content file types, such as:
    • CSS
    • JavaScript
    • common image formats
  • content referenced from other places on your site
    • this includes links like /path/to/asset.png or ../asset.png or /asset.png
    • it does not include links like https://site.netlify.com/path/to/asset.png
    • files not referenced directly by any page of the site will not be optimized

Note: If you reference a file/image without a preceding forward slash (/), this can cause the image not to be optimized. Why? This happens when the file is not in the same path as the page itself, so the file isn’t located where the asset optimization expects it to be. If we cannot find the file where it is expected, it won’t be processed.

Something else to keep in mind is that all content which is processed by the asset optimization system will always be served from a separate CDN (Content Delivery Network). Assets on that CDN currently always have a URL beginning with https://d33wubrfki0l68.cloudfront.net. Also, please note that even if an asset is unchanged (meaning not minified) for some reason, if it was processed by the asset optimization it will be served from this CDN.


About minifying JS, I noticed that it doesn’t work once the code contains “const” or “let”, but it works if we use “var” instead.
As it is oldschool JS, is there any roadmap to fix that ?

Hi there, @madsenfr :wave:

Thanks for reaching out. Could you share where you are saw this, or steps we can follow to recreate this?

Thanks for asking.
Here are 2 examples that demonstrate the problem very simply.
It’s the same very small and simple website, just using var in https://minify-var.netlify.app/, whereas it use const and let in https://minify-const-let.netlify.app/
Everything is explained in the website itself to see the original script and the one on CDN.
You will notice that var is minified whereas const & let are NOT.
Please let me know if you need anything else.

Is there any update on this one ?

Hey there, @madsenfr :wave:

Thanks so much for following up-- I assure we have not forgotten. I have resurfaced your question to our Support Engineers. :slight_smile:

Replied to your duplicate post here :+1:.

1 Like