Hosting your own JavaScript scripts files (other than Jquery) on fast free CDNs like google?

48.2k views Asked by At

Inspired by Dave Ward to host javascript files externally, I have several questions concerning the hosting of Javascript files externally:

Everybody knows that known libraries can be directly sources to, for free:

//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js

The scope of this question however focuses to hosting custom javascript files externally:

Q1. Is it possible to host private JavaScript files on a fast free public CDN?
Q2. Are there any speed penalties or is hosting on third party CDN practically always better?
Q3. Are there any safety risks involved in hosting custom JavaScript files externally?


Thanks to 13 people who have favorited this question, I am reopening this question! As of 2021, lightning fast websites (with all their JavaScript components) its more important than ever before to gather a collaborative understanding of objective ways to speed up page load. Untill this question is reopened, feel free to comment below your answer/suggestions to the three questions!

5

There are 5 answers

0
Stand with Gaza On

You can use CoralCDN which is a free cdn. It is unlikely to be as fast as Google's but it's free!

0
Josiah Nunemaker On

If your script is hosted on Github or NPM, I would suggest jsDelivr. It even allows you to target a specific version, or minify your scripts.

2
gamerboy On

jsdelivr is a free, fast and reliable service to host your javascript files on a CDN.
The file should be on github repository first, then use the following format to use the CDN:-

https://cdn.jsdelivr.net/gh/user/repo@version/file

In the above format replace user with your username on github, repo with repository name and version with the version of your repository
You can use this CDN service for hosted anywhere like npmjs.com or even on your wordpress sites using their plugin.
Please visit the website for more information and to know how it works.

7
Alex T On

EDIT: as of 2021-07-10 this feature doesn't work at codepen anymore.


codepen.io allows you to host some js files without registration. Once you have an anonymous codepen saved the js part of it is available by just adding a .js at the end of your url.

7
user1866612 On

I'm using http://yourjavascript.com for 3 years and happy with their free service.