Why UNPKG is free to use, and what will happen if I overuse?
Asked Answered
R

2

36

I know UNPKG is fast, reliable and free to use, but what if I overuse it, what will happen?

For example, I can use rollup instead of webpack to bundle my entire website as UMD build to a single JS, and publish it as a NPM package, and if I use React or Vue or any other SPA approach, the HTML markup all I need to ship to production is this minimum piece of code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>My Website</title>
    <script src="https://unpkg.com/my-whole-website-umd"></script>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

And UNPKG even help me to grab the latest version, which means if I publish my new package to NPM, my whole website that is in production will update:

<!-- this will always be the latest -->
<script src="https://unpkg.com/my-whole-website-umd"></script>

People can save thousands of server maintain money by using this approach.

Why UNPKG can still be free?

Ridiculous answered 3/2, 2020 at 14:46 Comment(5)
Linux is free. Firefox is free. Git is free. Node is free. It's not an uncommon situation.Biconcave
@Biconcave Linux, Firefox, Git, and Node are not hosted services.Dambrosio
@Dambrosio ah well it's basically supported by Google, so it's probably safe to make the paranoid assumption that Google extracts value from it somehow. edit also probably safe to assume that one morning we'll wake up and Google will have pulled the plug.Biconcave
This question should not have been closed. There's nothing "opinion based" about it.Dambrosio
This is a good question don't know why people voted on itKendrick
F
27

It started out as a fun project, and grew out to a popular service that many people use. Some big companies attached themselves to this project and donate their services and more may do so in the future. They may pull out their donations as their strategies change in the future. For the moment it's free. If the donors pull out it may go down or respond more often with 500 errors or turn into a paid service.

It's not a strictly reliable service as you would get with a paid CDN. But because it's free it's not strictly reliable, if money, donated services or motivation runs out, it might go down overnight. Good for hobby or low traffic projects, but don't depend on it for mission critical things according to this blog.

https://kentcdodds.com/blog/unpkg-an-open-source-cdn-for-npm

unpkg is great for open source project demos and instructional material (I use it heavily in my Beginner's Guide to ReactJS), but it's not well suited for mission-critical applications at scale because:

unpkg is a free, best-effort service and cannot provide any uptime or support guarantees.

That's why Michael recommends:

if you rely on it to serve files that are crucial to your business, you should probably pay for a host with well-supported infrastructure and uptime guarantees.

Felt answered 3/2, 2020 at 14:53 Comment(0)
O
18

The project is made possible by generous donations from Cloudflare, which serves 99% of our traffic through their world-class CDN, and Google Cloud which donates resources to run our backend infrastructure.

Taken from Patreon

Ophir answered 3/2, 2020 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.