DEV Community

Glenn Carremans
Glenn Carremans

Posted on

My Contribution to CDNJS

πŸŽ‰ My PR got merged into CDNJS after 7 months! πŸŽ‰

First a little bit about CDNJS

CDNJS is a public CDN that hosts most (if not all) of the popular libraries (JavaScript, CSS, ...). Because of this you can very easily include a library in your web application. If you are not familiar with NPM, build or bundle scripts, or if you just want to make a small static website using a public CDN is a good option. You also don't have to host the files yourself which might reduce bandwidth costs.

Another benefit of using CDNJS is that it is using Cloudlfare and because of this a library might be cached on one of their edge servers near you and this results in faster response times that also might increase your website loading speed.

It is also open source and for me that is a big bonus.

Why CDNJS?

There are of course alternatives (not going to talk about paid CDN providers).
A couple well known ones might be Google Hosted Libraries and jQuery CDN, the issue with these are that they only host a very select amount of libraries.

jsDelivr comes close to CDNJS. They also host almost all popular libraries and also use Cloudflare in combination with other CDN providers. This might seem better but because of this they have additional layers to route requests between CDN providers. Here is some information I found about this, however please note that it is written on the CDNJS Github by a CDNJS maintainer (but he is also a jsDelivr contributor).
The post is from 2016 so don't know how correct it still is. Maybe someone can provide more information in the comments.

Also as shown here CDNJS is used more than jsDelivr so that might give an increased cache hit from edge servers which results in faster response times.

My PR

It actually started in December 2017 where I asked on Twitter why CDNJS doesn't have SRI, well it does but not on the search results page. Here Peter Dave challenged me to make a PR for it.


So fast forward almost one year to October 2018, I found out about Hacktoberfest and wanted to contribute. Perfect project!

I never did anything in Node.js so it took some time to setup the project locally before I could start working on it. Thankfully there is a lot of information online and in the end it wasn't even that difficult.
So I made my PR and I waited, and waited, and ... No hard feelings to Peter Dave, I have been in the same situation. Making time for something can be hard. But finally last week Peter was able to review and test my PR and it got merged!

[Website] Added "Copy Script Tag with SRI" option to library search results #251

I do have experience in JS but this was the first time I worked with a Node.js project. I would perfectly understand if I made any mistakes.

So I have actually "reported" about this almost a year ago on Twitter and @peterdavehello challenged me to make a PR for it. I have never forgotten about it and now because of Hacktoberfest I decided to make some time for it and try it out.

I also saw some open issues about the same issue: Fixes #152 SRI support on search result Fixes cdnjs/cdnjs#12746 Add Copy Script Tag with SRI option

So now everyone can quickly copy a library link with SRI information directly from search results.

SRI copy

Link to CDNJS

Top comments (3)

Collapse
 
mattipv4 profile image
Matt Cowley

Thank you so much for an amazing contribution that should make so many developers' lives easier going forward when searching for a library quickly on cdnjs.

Collapse
 
glennmen profile image
Glenn Carremans

Thanks Matt! Did you really join DEV because of my blog post? πŸ˜„

Collapse
 
mattipv4 profile image
Matt Cowley

I think "join" is a bit much, simply pressed the sign in with GitHub button πŸ˜‚