Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 287
Sam Avatar asked Feb 07 '11 15:02

Sam


People also ask

How can I host a JavaScript file for free?

If you're looking to host your CSS and JS files for free, there are a few different options available to you. One option is to use a free web hosting service such as 000webhost.com or x10hosting.com. Another option is to use a free file hosting service such as Dropbox or Google Drive.

Is it better to download jQuery or use a CDN?

jQuery CDN generates functioning code that works in various browsers in a shorter time. On the other hand, Web developers require the jQuery download file to parse the library. Raw JavaScript may be faster for some processes, but the advantages of jQuery UI CDN outweigh the disadvantages.

Should I use CDN for JavaScript?

It is still beneficial to use a CDN, and it is still for your users' benefit, but the benefit is in reduced latency with geo-located servers, not in general performance due to a hot cache hit.


1 Answers

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.

like image 189
gamerboy Avatar answered Sep 24 '22 03:09

gamerboy