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
- this includes links like
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.