Fallback for CDN hosted jQuery

Several big companies offer copies of jQuery hosted on their CDN’s (Content Delivery Network). Most notoriously Google, but also Microsoft and jQuery themselves. A lot of people swear by this since it saves bandwidth, downloads faster, and perhaps even stays …

Avatar of Chris Coyier
Chris Coyier on

iPad Detection

Of course, the iPad is a pretty large screen and a fully capable browser, so most websites don’t need to have iPad specific versions of them. But if you need to, you can detect for it with .htaccess

RewriteCond %{HTTP_USER_AGENT} 
Avatar of Chris Coyier
Chris Coyier on

Facebook “Like” Button for WordPress

Some very easy copy-and-paste code here to add to the template for blog posts to allow for Facebook “liking” of the article. Probably best in the single.php template underneath where it outputs the content of the post.

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Trigger Click on Input when Label is Clicked

Labels should have “for” attributes that match the ID of the input they are labeling. This means we can snag that attribute and use it in a selector to trigger a click on the input itself. Assuming of course you …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Random Hex Color

Technique #1

<?php 
    
    $rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
    $color = '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
    
?>

Then echo out the $color value anywhere you need it. For example:

<body style="background: <?php 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Gift Message Printer

We have a client who sells a product in which customers specify a gift message when they check out. The site has been very successful for them and orders are coming faster than expected. The have been hand-writing the notes …

Avatar of Chris Coyier
Chris Coyier on

Loading Dots jQuery Plugin

Loading.... It's a design pattern we've all seen before, because it's just good user feedback. This is a quick jQuery plugin to apply it to any element when called (exactly in the middle of it).
Avatar of Chris Coyier
Chris Coyier on (Updated on )