My scenario:

  1. There's a blog that runs on Blogger, and that's also where it's hosted. Afaik, "external" (js) files cannot be hosted on Google's servers.
  2. When it comes to including popular JS frameworks (e.g., jQuery), there are several CDN options at our disposal.
  3. Looking for a jQuery-based Lightbox replacement for a blog, I've stumbled upon ColorBox; no plans to have a CDN for it though.

So far, when it comes to including/hosting the files under the given constraints, I've noticed the following suggestions/solutions:

  1. Including the minified version of the code inline in the Blogger template -- 9KB worth of JS code in a <script> element.
  2. Linking directly to the github raw version -- e.g., v1.3.16. (unreliable availability?)

Considering load speeds and availability what is the best practice for this scenario?

Accepted Answer

Based on what you describe, I don't see much benefit to not including the code in the Blogger template. It's arguably small enough that anyone not sucking their internet through a straw will not notice the increased time to download the page source, and it will certainly be faster overall than loading from a remote server, so it looks like the only likely performance hit is that you might have decreased responsiveness (time until the user can interact with the page), but it should only be noticeable if the user happens to have an especially narrow connection.

So, you'll have to consider your users, but unless an extraordinary number of them have narrow connections, just include the code inline.

Written by Gordon Worley
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki