Google CDN gets blocked… and how to fix the problem

OpenDNS Blocks GoogleDNS provider to the masses, OpenDNS have today blocked googleapis.com as phishing site. The result of this is hundreds of thousands of sites throwing up errors to users of OpenDNS (of which there are many).  It looks like this is an issue surrounding the SSL on googleapis, but similar problems have happened with the big Content Delivery Networks in the past.

If, like us, you found yourself scrabbling around switching CDNs today, then you might be thinking about a fallback solution. We’ve opted to move over to Microsofts offering with a fallback to googleapis.com in the unlikely event that it is unavailable.

To do that we’ve tweaked some code originally found via this post on weblogs.asp.net and come up with the following:

 <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.7.1.min.js"></script>
 <script type="text/javascript">
 if (typeof jQuery == 'undefined')
 {
 document.write(unescape("%3Cscript src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
 }
 </script>

Replace your standard CDN call with the above and you should be good to go. What’s more you have greatly reduced the chances of problems in the future.

All a bit hurried, so not hugely tested, but working for us so far.

(If this seems to you like a weird place for this post to appear, I agree! However I wanted to share this and couldn’t think of where to do it, so used a blog that I was planning to do something with in the future)

By

Mat Bennett is long serving web geek and MD at Brit-net Internet marketing, a Hampshire based web development and marketing agency.