JojoCMS / Jojo-CMS

Jojo is an SEO-friendly, fast, and extensible PHP-based CMS
http://www.jojocms.org/
GNU Lesser General Public License v2.1
20 stars 8 forks source link

Local js fallback for CDN #7

Closed jaiivarsson closed 9 years ago

jaiivarsson commented 12 years ago

A new practice for using CDN is to test it is there and if not load it from a local copy. Like this:

<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
 <script>window.jQuery || document.write('<script src="js/libs/jquery-1.5.1.min.js">\x3C/script>')</script>

Thinking this is a good thing to add.

Hambrook commented 12 years ago

It sounds good... I've seen an attribute on either a script or stylesheet include called something like fallover, fallback, failover or something that listed a local path to compensate if the CDN failed... But I can't remember nor find any reference to such an attribute now. It could've been custom, I don't know but I'll keep looking.

Hambrook commented 12 years ago

Also, I like the idea of using // instead of http{if $issecure}s{/if}:// where applicable.