Cloudflare minification is terrible

Take this minified file https://cdnjs.Cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js and check it’s size. It’s around 85KB.

Now get the unminified version at https://cdnjs.Cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js which is around 250KB.

Now take the unminified version and put in your webserver that uses Cloudflare. Enable CSS/JS/HTML MINIFICATION. Now try to access the file on your browser.

I did exacty that. Indeed, Cloudflare IS MINIFYING the file HOWEVER the final size is 140KB! Is terribly minified, it’s almost twice the size of the already minified file provided by Jquery library.

What is going on? Why does Cloudflare minification is so terrible?

I guess when cf says minification they mean only remove white space and some new lines, while cdnjs actually taking another step and uglify the code to make it smaller(changing variable names and other tricks)

I understand Cloudflare as when you entering into uglify you can end up with some bug and errors and some rare edge cases they probably cant count on it in their scale…

but the real answer is: don’t count on Cloudflare for js minification… just minify it yourself

1 Like

That’s what I guessed… Cloudflare minification is terrible, it is only removing newlines, spaces and a few comments (not all comments are removed).

@contato as boynet2 said, when resources are loaded on to cdnjs, we take extra steps to minify the files ourselves if the source of the resource has not already minified it. In the case of jQuery, they actually minify the files themselves which we then simply serve on cdnjs.

Most library authors minify their code and uglify it at the same time, reducing the byte size far more than just removing whitespace and comments. Take a look at a service like https://jscompress.com/ for how compressed JS code can become :slight_smile:

Hope this helps.
Matt - Community Manager @ cdnjs.com

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.