Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: why did you change from unpkg to jsdelivr? #12

Closed
jthegedus opened this issue Jan 28, 2019 · 4 comments
Closed

question: why did you change from unpkg to jsdelivr? #12

jthegedus opened this issue Jan 28, 2019 · 4 comments

Comments

@jthegedus
Copy link

Just curious

@jhildenbiddle
Copy link
Owner

Hi @jthegedus.

I made the switch after an unpkg bug broke redirect URLs (see mjackson/unpkg#156). Bugs happen, but this particular one took a long time to fix and was very hard to verify that the fix worked for everyone. As I mentioned in the linked issue:

Moving forward, I have decided to change the CDN links listed in my packages from unpkg.com to jsdelivr.com as a result of these redirect issues. As much as I appreciate unpkg.com and the unique "automated CDN from NPM" offering it pioneered, jsDelivr offers similar automated CDN services for npm packages along with additional features like support for GitHub repos, package statistics, automatic bundling and minification, and subresource integrity checks.

The only hiccup I've experienced is that jsDelivr content is cached longer on both the server and the client, so getting the latest version immediately after release requires extra fiddling or patience. I mentioned this in a jsDelivr issue (jsdelivr/jsdelivr#18124) to which I received this helpful response from @MartinKolarik:

The approach taken by unpkg almost completely eliminates client side caching because your browser makes a request for each file every minute. If there wasn't a new version, the file content isn't transferred again, but there's still the cost of making all those requests, and it can have a significant impact on the performance of your website.

Makes sense, so I now do the following:

  • I use unpkg when I am using a version redirect URL (e.g. @latest, @1, @1.2) in development to ensure I'm getting the very latest version.
  • I use jsdelivr when I am using a version redirect URL in production or specifying a version (e.g. @1.2.3)

Seems to be working well so far. 😄

@jthegedus
Copy link
Author

jthegedus commented Jan 28, 2019

Very useful information. Thanks again for taking the time to formulate such a useful answer 😄 It'd probably be useful to have a comparison in Docsify.

@jhildenbiddle
Copy link
Owner

You bet. Happy to help.

FWIW, I've filed an issue (docsifyjs/docsify#756) suggesting the maintainers consider making the same switch. It's easy enough for folks to choose jsDelivr over unpkg on their own if they are aware of it, but I suspect many docsify users blindly copy-paste the links provided in the docs.

@jthegedus
Copy link
Author

Your are 100% correct. I'm aware of unpkg, but was not aware of the differences between CDNs so blindly used unpkg. I think recommending unpkg during development and jsdelivr for prod stability is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants