Minify JS not working

Minify JS under Deploy Settings, Asset optimization: isn’t working for me. I have a plain HTML project, no build tools. CSS is being minified, yet JavaScript is not being minified. Bundle JS works. Please help.

2 Likes

hi there, can you give us a little more information, please? The name of your netlify site (not custom domain) would be helpful - also a screenshot of your asset optimization settings.

thanks!

Hello Perry. Thank you. The site is https://sad-wright-da6669.netlify.app
A screenshot of my settings is attached.

hey titani,

thanks for that. I do indeed see that your JS, located here:

https://d33wubrfki0l68.cloudfront.net/bundles/57c3aa1413f26f2a0edcc42507aee46792be6397.js

doesn’t seem to be minified :thinking:

I am going to let someone else who knows this topic a bit better than I do weigh in. I bet we can figure it out.

Very good. Thank you.

Was this ever resolved?

Hi, @pspeter3, I don’t see that it was. @titani, if you want to keep troubleshooting this issue, please let us know.

Do you have content not minified, @pspeter3 ? If so, what is the site name and the URL for the content not minified?

Hi @luke, I am having the same issue with my JS not minifying,
https://proven.netlify.app/

could you post a screenshot of your asset optimization settings please?

This is still and issue. Any news on it?

Is Netlify supposed to minify resources from a third party? The file in question is not hosted with Netlify but pulled directly from cloudfront?

I had the same problem and made some tests.
JS is not minified once you use keywors “const” or “let”, but it works if you declare your variable with “var” instead of “const” and “let”, but it’s oldschool JS.
Does anyone knows if there will be an update any soon ?

1 Like

Interesting findings! Thanks for digging that up, it’ll be useful when the team invest time in to our post processing features. Nothing to report just yet however we appreciate the outreach!

1 Like

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.

Related post : [Support Guide] Does Netlify optimize every single asset my site uses? - #23 by hillary

1 Like

Interesting find! Must be some logic in the minifier to not minify for const/let (491 v 762 bytes) as they’re both handled by our post processing (served from Cloudfront).


If this is important to you, right now, I’d advise minifying externally. Again, thanks for showcasing this!

1 Like

I knew it was processed, because scripts are on CDN.
This is an example, but my real scripts are must larger, but as they use const and let, they are not minified.
It was quite interesting not to do minify by my side and let Netlify do it.
I’d rather expect that you take this in account, as most script must not be minified with such widely use JavaScript keywords.
I undestrand it’s not a priority, but it should at least appears in a roadmap or in a bug list to fix.

Is this still an issue? My project is also a simple static site using HTML/CSS. No build tools. However, post processing does not work at all. No compression of HTML, CSS and image assets.

Looking for a solution.

Hi @sam19,

Do you have a website URL to share?