Do you reference your code from Google or on your server

Curious to know how you guys would call say a jquery file. From your own server or from the Google Library API?

Hey guys,

Me and the company I work for (http://alterimaging.com) are actually the ones who developed scriptsrc. Thanks for the mention Alex!

Scriptsrc actually pulls the information from googles servers every night, so all of the javascript files are still hosted by google. We just provide an easy way for the community to get the exact urls. It checks google nightly and updates our database of urls and other information as well as tweets out any new versions through @scriptsrc.

Thanks again for the mention!

While that’s true, this one seems to be gaining a LOT of support due to it’s simplicity for beginners (whereas Google’s requires coding knowledge), in either case, mirrors are always useful even if only for the bandwidth saving (as it’s cross domain), the caching is just a useful extra for the end user :slight_smile:

I personally call it from Google.

If you use the Google one then a lot of your visitors may already have it cached from having already visited other sites that also use the Google one.

interesting observation about cache. I’ve never thinked this way. I’ve allways thought that a js from my server is loaded faster

There’s another website hosting the various frameworks:

http://scriptsrc.net/ <<< Pretty useful cloud hosted solution. :slight_smile:

You can call from jQuery’s site as well. Their servers are built for it.

The advantage to referring to jQuery or google is that your visitors have a higher chance that they’ve already cached that library from visiting some other site. That means faster loading and one less request for you… having it on your server means people are making a request for it.

I would assume the day the google or jQuery servers are down, the whole internet is down, so in this case I don’t see any benefit to keeping the copy on your own server.

The problem with more than one “cloud” hosting solution is that the chances of a given visitor having the file cached is reduced as the other site they may have visited used the copy from an alternate host. If everyone accessed the files from the one place that would make it as fast as possible since every visitor only has to download the file for the first site they visit that uses it.

Either is fine. I prefer my own server, but with the Google one, you can set it to use newer versions as they come out, their delivery is very fast, and it will save you a teeny bit of bandwidth.

In addition to what Stephen said think of it like this. 99.99% of people on the internet have in some way connect with Google. But your site would hit less, thus less likely they have it cached.

One thing to think about if using plugins is to make sure you reference a specific jQuery version that you know works with them. Referencing it generically may cause things to break.

I’ve allways thought that a js from my server is loaded faster

It might, if the external server (google or jquery.com) are having a slow moment or whatever while your server is at peak running speed.

Although, unless it’s a large difference in time, I’d also save the bandwidth money and let visitors grab from the big guys (and again, they set their servers up for high traffic partially for this reason).