Category Archives: Coding

Using Google-Hosted jQuery With a Local Fallback

Referencing commonly-used JavaScript libraries, like jQuery, stored on Google’s CDN is a good way to speed up your site. Many popular websites do so, which means the chances of a user having jQuery sitting in their browser cache already is pretty high. It doesn’t make a whole lot of sense to download it all over again for another website, does it? Using the copy on the Google Libraries CDN just makes a lot of sense.

But what if the servers Google has hosting it went down for some reason? Given Google’s track record, it’s not likely to be an issue, but it’s a good point. Fortunately, you can easily reference a backup. You can have a copy of jQuery on your server, and use a little bit of JavaScript to load it only if the Google one doesn’t load for some reason.

This little snippet, found in HTML5 Boilerplate, will do just that:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.4.min.js"><\/script>')</script>

This should even work with WordPress, if you put the second script line right before the </head> tag in your theme.

Building an iPhone App to Parse the Twitter API with NSXMLParser

iOS has a simple event-based XML parser built in, which makes it fairly easy to do less involved parsing operations without having to load up a third-party framework. This tutorial will show you how to build a simple iPhone application that will download an…

If PHP Were British

I was browsing a popular social media site the other day, when I came across a link entitled “If PHP Were British.” I started laughing out loud (for real) just a few paragraphs in. When Rasmus Lerdorf first put PHP together, he – quite…

Getting Your Feet Wet with PDO and Migrating Old MySQL Code

You may have heard that the old MySQL extension for PHP is going to eventually be deprecated in favor of the newer (and potentially more secure) MySQLi and PDO extensions. You’re going to need to update your old code sooner or later, so why…

Google +1 Content Unlocker with jQuery

You’ve probably seen sites like MacHeist and Make Use Of run promotions where you can unlock a software license or enter a drawing for an iPad by posting a message to Twitter or Facebook and then entering your email address into a form that…

Microjs: Micro-Frameworks and Micro-Libraries

Sometimes you don’t need a huge JavaScript library like jQuery or Prototype. Sometimes all you need is a small subset, like AJAX functions and templating. If a project doesn’t need all 31kb worth of jQuery, why don’t you try something a bit lighter? Microjs.com…

PHP to Deprecate MySQL Extension in Favor of MySQLi and PDO

The PHP project is working toward “softly” deprecating the mysql extension and its associated functions in favor of the newer (and more secure) mysqli and PDO extensions. They won’t be adding E_DEPRECATED errors for the extension in PHP 5.4, but will consider it in…

Get Twitter and Facebook Link Statistics with JSON and jQuery

Both Twitter and Facebook have little JavaScript widgets that allow you to share a page using the respective service, displaying a running total of users who have done so. While that’s fine for most purposes, what if you just need the count, for some…

The PHP Forking Has Begun

I previously mentioned my wish for an overhauled, more object-oriented PHP, a desire shared by many developers who work with PHP on a regular basis. Well, the long journey toward such a thing might have just started. Someone has forked PHP, making quite a…

So I Finally Figured Out Why Everyone Likes Git Repositories so Much…

Until recently, I didn’t really use version control software all that much. I primarily used SVN for a few WordPress plugins, as WordPress maintains a free repository on their SVN server for each plugin a developer submits. While I found it interesting, I didn’t…