DEV Community

Discussion on: I reduced an npm package size by 50% with minification

Collapse
 
dagnelies profile image
Arnaud Dagnelies

Well, the whole purpose of a CDN is to make things load faster. Your statement / question is quite confusing.... And loading a minimized version of anything looks like pretty useful to me.

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️ • Edited

I think maybe he was getting at the bundler question. This is the area where the debate is for me. It's arguable that if some of your dependencies rarely change, then it may be better leaving them out of the bundle and loading them externally from a CDN. This will reduce your bundle size, and all these unchanging dependencies will be cached locally (+ fast loading initially). I believe there are plugins lying around that can make specified dependencies use Skypack in production builds.

Thread Thread
 
seven profile image
Caleb!

Great! Thank you for pointing this out too. 🚀

Thread Thread
 
seven profile image
Caleb!

Just to be clear again...

It'll be better to do something like

import React from "skypack/link/that/points-to-the-react-package" 
Enter fullscreen mode Exit fullscreen mode

Instead of the normal way. Yeah?

@jonrandy

Thread Thread
 
dagnelies profile image
Arnaud Dagnelies • Edited

It depends. If you pull a library "from the browser", it is preferable to be minified. If you pull a library "in your npm project", the sources are often preferable, since the whole app is bundled/minified in the end anyway.

Thread Thread
 
seven profile image
Caleb!

Now, this is clear.

Thank you! 🍷