9 ms·
CDNJS: The Fastest Javascript Repo on the Web
- atonse 14y agoI've recently started using CDNJS for my projects. Thanks to Ryan, Thomas, and CloudFlare for this awesome service! Even happier to see that you guys host CSS and images for the common libs. I will change my bootstrap css hosting over to yours soon.
- cypherpunks01 14y agocdnjs is a great public service, I've been using it for various projects for awhile and it seems consistently fast everywhere.
- nikcub 14y agothis shouldn't be hosted on the cloudflare.com domain. since I am a customer every request sends my cloudflare session cookie and a bunch of Google Analytics cookies. Not only is it 2.5KB of extra header info sent, but I don't think cloudflare should know which websites their customers have been visiting.
- graue 14y agoYeah, that is an odd decision. Makes you wonder if the “secret” motive of CloudFlare in hosting this, other than to promote their service, is to track and analyze your visitors. I don't see a privacy policy on CDNJS.com. I'd definitely like to know what data they collect about my visitors and what they do with it. At least the CDN doesn't itself set any cookies.
- untog 14y agoHonestly, I don't think that it is some conspiracy to track me, rather it was just a mistake. Perhaps I am not cynical enough.
- atonse 14y agoIf anything this would only work on other cloudflare users (like people who logged in to cloudflare). Most users won't have any cookies on that domain.
- bigiain 14y agoThere's nothing to stop them setting cookies in the responses down the track though. Wait until you've got enough users, then one day just switch on your 3rd party multi-site user tracking. Or perhaps less publicly dicoverable, use browser fingerprinting and ip address correlation to do the same thing with somewhat less accuracy, but completely invisibly. And note too, that if you're relying on a 3rd party to serve javascript your users are going to run in their browsers - if that 3rd party isn't trustworthy, you're screwed in much worse ways that cookie tracking privacy violations. Who'd notice if they started occasionally serving a modified version of jQuery which sent all form field keydowns (aka, your usernames and passwords) back to theselves?
- graue 14y agoThis is way too paranoid. CloudFlare are a reputable company; they're not blackhats. I think my comment above was too paranoid, as well, but it's too late to edit. All I was suspicious of was that there might be analysis going on.
- atonse 14y agoFollowing the money will especially help in this situation. How does CloudFlare make its money? It's a CDN company. I mean, that's the CORE of what they do. What is jsCDN? It's a CDN. A simpler theory is that hosting a Javascript CDN (and demonstrating that it's even better than Google's, which is amazing), is going to provide a lot of free advertising for their product. If I use their CDN for JS and it works really well, I'm likely to go back to them for hosting other things, because using jsCDN is almost like doing a free trial of their actual CDN. It's not even like their main form of income is in another industry that we have to make a cognitive leap to see what their ulterior motives are. It's precisely this. CDNs.
- bisho 14y ago
- byoung2 14y agoMicrosoft just changed their CDN url because of this: http://www.asp.net/ajaxlibrary/cdn.ashx http://www.asp.net/ajaxlibrary/cdn.ashx Though for the most part, people will not have cookies set on the domain unless they have visited the main site (i.e. they are developers).
- cypherpunks01 14y agoCould you set up a CNAME on your website that points cdnjs.mycompany.com to cdnjs.cloudflare.com to solve this (for your site visitors)? Or would that mess up cloudflare's anycast DNS?
- marshray 14y agoWouldn't the browser still send cdnjs.mycompany.com in the Host: header and break the page?
- nikcub 14y agothat is exactly what happens. the server isn't setup to respond to requests to the cdnjs.mycompany.com hostname and it returns a 409 error.
- cypherpunks01 14y agoAh, thanks for the info. Damn virtual hosts!
- eastdakota 14y agoThere is no cookie information (CloudFlare, Google, or otherwise) sent for requests to CDNJS resources.
- dknecht 14y agoIn addition the reason to host this on single domain vs your own site is that the users only have to download the resource once it once for all the sites they visit.
- nikcub 14y agothe first thing I did is request backbone.min.js and open the web console to check the response time. looked at the request, saw cookies: http://i.imgur.com/Qqzc3.jpg http://i.imgur.com/Qqzc3.jpg
- alexchamberlain 14y agoWe can still improve this by caching across CDNs.
- byoung2 14y agoYou mean updating browsers to recognize the same file across different domains (e.g. md5 hash, etc)?
- alexchamberlain 14y agoI mean this... http://alexchamberlain.co.uk/opinion/2012/09/13/cache-across-domains.html http://alexchamberlain.co.uk/opinion/2012/09/13/cache-across...
- nikcub 14y agothe reason this hasn't been done is: a) would require all servers and browsers to be updated for what is a marginal gain b) privacy nightmare
- alexchamberlain 14y agoa) No it wouldn't; it would be totally optional. b) Get over it; there is no difference between this and CDNs.
- nikcub 14y ago> Get over it; there is no difference between this and CDNs. except the part where you track people across sites what I am saying is not speculative. this has been proposed previously, and shot down. there is a reason why it hasn't happen.
- alexchamberlain 14y agoWhere would you be tracking people across sites?
- IanDrake 14y agoQuick question... I thought the best part of CDN hosted js files was that they were more likely already cached on the client, not so much for the speed of delivery. So, wouldn't it be better to go with the most popular and not the fastest?
- graue 14y agoFor jQuery, maybe. But if you're using, say, Backbone, that point is moot because only CDNJS has it. The Google CDN[1] only hosts 11 libraries, CDNJS hosts over 200. 1. https://developers.google.com/speed/libraries/devguide https://developers.google.com/speed/libraries/devguide
- 0x006A 14y agois the chrome extension[1] working? was just thinking that I might start to use it if there was a browser extension that makes sure those requests stay always local. otherwise its rather slow to use any remote resource while developing a page locally. https://github.com/cdnjs/browser-extension https://github.com/cdnjs/browser-extension
- scosman 14y ago+1 to joshfraser - cache hits always beat requests. I remember seeing a stat about n% of top 100 sites use the google CDN for jquery, it was by far the most popular. Stick with Google for popular libraries.
- eric_bullington 14y agoFor analytics and tag generation of libraries hosted by CDNJS, take a look at: http://www.scriptselect.com http://www.scriptselect.com It's a weekend project I did a couple of weeks ago using d3 and backbone. You can select libraries, view selected library size, and copy the generated script tags for the libraries you've selected. Just a little tool to make using CDNJS a little more convenient. If there's enough demand, I'll add other CDNs. Thanks to Ryan, Thomas, and CloudFlare for a very cool service!
- jread 14y agoLow latency with a handful of pingdom monitoring nodes sitting in data centers does not necessarily translate to the "fastest repo on the web". We've tested CloudFlare since their launch using thousands of real users, and based on that testing performance tends to be on the low end compared to traditional static content CDNs. CloudFlare is more of a website proxy than CDN. By assuming full control of your website DNS, it stands out more with add-on features like security. Here is a link to some real user performance analysis I've compiled for various CDNs including CloudFlare: http://dl.dropbox.com/u/20765204/feb12-cdn-report/index.html http://dl.dropbox.com/u/20765204/feb12-cdn-report/index.html
- ksec 14y agoI have similar experience with CloudFlare. The Speed just isn't there. Most CDN perform MUCH better then them. I would love to pay to even get faster speed. But that is not the model they decided to work on. I hope they will have more speed improvement coming in soon.
- moe 14y agoBacking up wild performance-claims with a Pingdom chart? I really don't know how anyone can take CloudFlare seriously anymore...
- po 14y agoThey say this is 'peer-reviewed' but is that all? If someone sends them a pull request for an update to a widely used but perhaps smaller library, will they review it or does it just get merged into the CDN? It seems like a good way to get access to millions of browser sessions. Is anyone in Cloudfare taking responsibility for checking that the code is coming from the authoritative repo and not joeblow/underscore.js? https://github.com/cdnjs/cdnjs#pull-requests-steps https://github.com/cdnjs/cdnjs#pull-requests-steps While Google and Microsoft are slower to update their libs, we can assume that they are downloading releases from official sources.
- thomasfromcdnjs 14y agoContributors generally include the links to the official sources. If not we track down the official repositories ourselves. Once we have verified the source, we then check the diff against the submitted and official. We have always flirted with the idea of a level of automation to handle this. But your comment addresses the problem with a solution such as that so we are still manually diff checking for maximum security.
- joshfraser 14y agoThe fastest request is the one that never happens. One of the biggest benefits of using hosted libraries is that browsers cache those files locally. By sharing the same URL for your copy of jQuery with thousands of other sites, you increase your odds of getting a local browser cache hit. For popular libraries like jQuery you're probably best using Google since they have the most adoption. That said, I think CloudFlare's CDN is an interesting idea and could grow into something genuinely useful especially for less popular libraries.
- daemon13 14y agoThe question I have [but not the answer] is: Usually in every project there is bunch of .js [jquery, backbone, etc] and .css files. So the good practice is not only to minify and compress, but also to bundle some/all of them into several big combined files to save on extra HTTP calls. So my question is - what is better - (1) have separate files served from such CDN [or any public CDN] or (2) combine the files and serve yourself by nginx/AWS? Not a developer, feel free to correct any mistakes :-)
- joshfraser 14y agoIt's a great question. The answer depends on a lot of different variables like your cache hit ratio, the size & number of files, etc. I'd recommend doing a performance A/B test using JavaScript to time which one is best for your particular site. We offer a free Real User Measurement tool at Torbit (http://torbit.com http://torbit.com) that includes the ability to do A/B tests like this.
- ksec 14y agoDepends how many files you have, but for a general answer it should be 1.