Archive for month: April, 2012

Video: Is Node.js Better?

Categories: javascript, Node.js

Brian Ford (@brixen) gives a very interesting talk @ jsconf 2012 about the conversation of ‘which is better?’. He points out that humans really don’t do well at comparing things.

He looks at the support and excitement in the Node.JS community. How javascript has a large number of developers, but perhaps has some challenges in the future. Then looks at ruby on rails -vs- node.js.

About Brian Ford

Brian has been working on Rubinius since December 2006 and with Engine Yard since January 2008. He created the RubySpec project to improve the standards for high quality, consistent, and compliant Ruby implementations. He hopes to improve Ruby and thereby make the lives of developers even better. He enjoys whisk(e)y but will accept good wine in a pinch.

WordPress Tutorial: Load the jQuery Library from CDN

Categories: jQuery, SEO, Wordpress

Some might say there is really just 1 thing to remember about making good WordPress website. Make it fast. Speeding up your WordPress site will improve user experience and also improve your sites SEO. Using a CDN to distribute your jQuery library is a great place to start.

There are at least 4 reasons you should use a CDN to service jQuery on your page:

  • 1Decreased Latency
    Content Delivery Network — distributes your static content across servers in various physical locations. The User’s download will automatically target the closest available server in the network.
  • 2Increased parallelism
    To avoid needlessly overloading servers, browsers limit the number of connections that can be made simultaneously. Depending on which browser, this limit may be as low as two connections per hostname.
  • 3Better caching
    Potentially the greatest benefit of using the Google AJAX Libraries CDN is that your users may not need to download jQuery at all. If your user had downloaded the content in the past, it may already be cached.
  • 4Reduced bandwidth costs
    If someone else’s CDN is pushing the content to your users, they are using their bandwidth, not yours.

All of these reasons add up to fast responsive websites. That may be the one thing that everyone agrees is a good thing.

WordPress: Google’s jQuery CDN

I spend a good amount of time working in WordPress environments. Seems like every theme comes with jQuery and the all use the local copy, obviously that is not a great idea, luckly there is a simple way to correct this oversight with just 6 lines of code.

function jquery_cdn() {
   if (!is_admin()) {
      wp_register_script('jquery', '', false, '1.7.2');
add_action('init', 'jquery_cdn');

Other jQuery CDN options

While I recommend using the Google CDN because it is so widely used and therefore increases the changes it will already be in your user’s cache, there are several other options.
Google’s jQuery CDN

Microsoft’s jQuery CDN

jQuery’s CDN

Other jQuery CDN Version Options

Most of the CNDs listed above will also service other versions of jQuery. For example if you wish to use jQuery 1.5.2 from Google’s CDN it is simply a matter of requesting

jQuery $(document).ready() shorthand

Categories: javascript, jQuery

jQuery .ready()

JavaScript provides the load event for executing code when a page is rendered. This event gets triggered when the download assets such as images has completed. However, most people want their script to run as soon as the DOM hierarchy has been fully constructed. jQuery provides the .ready() for just this purpose.

$(document).ready(function() {
  // your code
  alert('Page: ' + $('title').html() + ' dom loaded!');
$(function() {
 // Handler for .ready() called.
 alert('Page: ' + $('title').html() + ' dom loaded!');
(function($) { 
  $(function() {
   // by passing the $ you can code using the $ alias for jQuery
   alert('Page: ' + $('title').html() + ' dom loaded!');

.ready() Handler

The handler passed to .ready() is guaranteed to be executed after the DOM is ready. This is usually the best place to attach all other event handlers and run other jQuery code. If .ready() is called after the DOM has been initialized, the new handler passed in will be executed immediately.

© 2012 - - Unseen Revolution LLC. 333 NW 4th Ave. Portland, OR 97209
By Portland, OR Category: Webinar Portland, OR Category: Webinar Portland, OR Category: Webinar