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

5

19

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!

Leslielesly answered 7/2, 2011 at 15:45 Comment(1)
For those who use github, there is an easy way to convert your github link to jsdelivr. go to jsdelivr.com/githubZechariah
H
33

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.

Horvath answered 6/1, 2019 at 8:45 Comment(2)
+1 for jsdelivr. It has been consistency helping me in hosting assets in cdn. It accepts files from GitHub, Google Hosted Libraries, RawGit and unpkg.Felicitasfelicitate
I've enjoyed jsDelivr for years, but it has been very flaky of late. 404 errors, inability to update the cache on changes, very slow updates on new GIT releases. Be cautious. Also make certain your repo is public.Gauntry
A
14

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.

Absa answered 18/10, 2018 at 9:47 Comment(7)
This works also for css, probably for html too.Myocardium
there's a 1mb limitLackey
Does not work for me.Myrt
Ok, registration now is needed at codepen to do it. Not a big deal.Absa
even with registration, I can't make it work: when I add .js and try the resulting URL (https://codepen.io/username/pen/UNIQUEID.js) it gives Pen Not FoundMagdeburg
Thanks @VasilyA, indeed doesn't work anymore. Updated the answer to avoid confusion.Absa
Investigating this, I was told by Codepen that the ability to access files (.js, .css, etc) directly and externally still exists for PRO members. Can anyone confirm this? I have a lot of sites with low traffic and often-tweaked JS files where Codepen would be an ideal solution, if it can work.Gauntry
A
10

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

Avar answered 28/12, 2012 at 7:59 Comment(7)
It doesn't send the link for your js files -it's useless.Bangle
Note that this has a 1MB upload limit.Mesopotamia
doesn't appear to use httpsEnhance
Doesn't seem to let you update previously uploaded files....you get a new URL each time...which means you have to go update all source files which reference the hosted file.Nicosia
Doesn't use https and hence isn't allowed on CodePen as one example.Discarnate
Does not work. No link is sent to emailQuitt
As of July 15 2022, the site appears to be unreachable.Gauntry
B
4

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

Bini answered 7/2, 2011 at 15:58 Comment(0)
A
1

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.

Asperity answered 31/7, 2018 at 1:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.