The #1 way to speed up your website is to minimize HTTP requests, however; inevitably you will make request for images, audio, video, code, and other content. Whenever; you can off load some of the content to other domains or to other servers your site will always load faster. However; there will be times when those ‘other servers’ will be down. Whether it is just for a moment or for a longer period of time, you do not want your site to be at the mercy of those servers. What can you do? (Glad you asked). You can have the best of both worlds. Why not check to see if the ‘other’ server is available. If it is then use their servers to deliver your content. If not then just load your own content from your site. It is not that hard to do and takes about 3 more lines of code. You can use this for anything in particular. Just find the piece of code to check for.
I am giving you this example of the jQuery library and any library will do just replace the code with the syntax for their library.
[sourcecode language=”javascript”]<br />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script><br />
<script type="text/javascript"><br />
if (typeof jQuery == ‘undefined’) {<br />
document.write(unescape("%3Cscript src=’../javascript/jquery-1.6.1.js’ type=’text/javascript’%3E%3C/script%3E"));<br />
}<br />
</script><br />
[/sourcecode]
I do not think this needs a lot of explaining but just in case here we go.
Line 1: Load of the library from a CDN (Content Delivery Network).
Line 2-6: Checks to see if the library got loaded. If it did not then inject your library into the page. Then on the load it will then load yours and not the one from the server. This
way you never load it twice but you always use the one from the CDN.
Looking for reliable web hosting? Then look no further than Arvixe!