My Contribution to CDNJS
Tags: opensource, cdnjs, javascript, webdev
Published: 2019-05-08 15:52:17

**🎉 My PR got merged into [CDNJS](https://cdnjs.com/) 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](https://developers.google.com/speed/libraries/) and [jQuery CDN](https://code.jquery.com/), the issue with these are that they only host a very select amount of libraries.

[jsDelivr](https://www.jsdelivr.com/) 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](https://github.com/cdnjs/cdnjs/issues/7715) 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](https://w3techs.com/technologies/comparison/cd-cdnjs,cd-jsdelivr,cd-googlelibraries,cd-microsoftajax,cd-jquerycdn) 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.

{% twitter 944140219049234433 %}
{% twitter 944211331795763200 %}

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!

{% github https://github.com/cdnjs/new-website/pull/251 %}

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

![SRI copy](https://thepracticaldev.s3.amazonaws.com/i/pwg14m8jzq2qqwljsq1n.png)

[Link to CDNJS](https://cdnjs.com/)