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)

12 thoughts on “Google CDN gets blocked… and how to fix the problem

  1. As above, won’t work as you’re still calling the remote address (which is currently blocked by OpenDNS). You need a local copy of the jQuery file as the fallback, e.g.

    <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script>
    <script>window.jQuery || document.write(“\x3C/script>”)</script>

  2. Obviously it’s a bit of a quick and imperfect fix but it’s done the job we needed it to do and in a reasonably short amount of time.

    As we know that similar issues are not currently affecting the Microsoft CDN, we simply decided to switch over, thus google now becoming the fallback solution.

    Taking into account the obvious advantages of utilising a CDN opposed to a local solution, it made sense that the fallback should indeed be another CDN, seeing as the chances of both being simultaniously unavailable are reasonably remote.

  3. i try to do this …. end up my wordpress drop meun can not working can you get me solution ?
    <script type="text/javascript" src="

    if (typeof jQuery == ‘undefined’)
    {
    document.write(unescape(“%3Cscript src=’

    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”));
    }
    ‘ type=’text/javascript’%3E%3C/script%3E”));
    }
    “>

    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”));
    }

Leave a Reply

Your email address will not be published. Required fields are marked *