loading...
markdown guide
 

As in most cases the answer is: It depends.

Even though CDNs are made to be reliable. It is a resource you have no control over. Maybe they will clean up the content after a while and remove (little used) resources. Maybe the CDN is blocked for the users. etc.

So, it depends:

  • how quickly can you adept your program to resolve CDN related issues
  • are there network accessibility constraints (think: corporate networks)

The company I work for makes so called enterprise software. So I have made it a rule to not use CDNs for anything we can host ourselves.

But for personal projects or PoCs I often do use CDNs. But once I start approaching shippable products I try to in-source the resources as much as possible.

 

I agree with all of this. I'll add that if you can add the npm package and include the library as part of your build with the rest of your code, your code should be cleaner. You can rely on imports instead of global variables.

All-in-all I'd call the CDN a quick and dirty version or a good solution depending on your needs, but when in doubt, make it part of your package.json.

Disclaimer: I'm always uncertain about anything in JS land these days 😄

 

It depends, there are many solutions to this.

You could create your own CDN (makes sense if you're not using HTTP/2)
You could use the provided CDN (please use a subresource integrity check)
You could combine the assets using a build system and serve that file (I recommend using some kind of cache busting and cache that big file locally)

Or just install the dependencies and serve them directly, it all depends how much effort you want to put into this and what you think it's gonna be valuable for you.

 

I'd recommend using CDN when you're just playing around. It's quick & cheap way to experiment but rely on packaging when you're deploying to something of importance (i.e. in production).

Packaging gives you dependency management, source control, static checks / analysis. If the cost of hosting the CDN is too high, then roll your own (or use of them CDN as service tools).

If you're in the corporate world, in either case you'll have to worry a lot more about licensing, source code correctness, security and accessibility of code / CDN.

Classic DEV Post from May 10 '19

Discuss: GitHub Special Event

GitHub is holding a "GitHub Special Event" today. Let's discuss what we're thinking leading up to it + while it's happening <3

Jess Chandler profile image

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

P.S. You can also change font to sans serif, which a lot of folks prefer. 💖

P.P.S. It's also the best place to talk code amongst thoughtful developers, and it's totally open source