The need for whitespace

I’m a big fan of vertical whitespace, and find it strange that more fuss is made of tabs vs spaces (which doesn’t really affect readability) than vertical spacing (which does).

Here’s a simple code example, randomly picked:

$max_width  = intval( get_option( 'thumbnail_size_w' ) );
$max_height = intval( get_option( 'thumbnail_size_h' ) );
// last chance thumbnail size defaults
if ( ! $max_width && ! $max_height ) {
  $max_width  = 128;
  $max_height = 96;
}

Compared to:

$max_width  = intval( get_option( 'thumbnail_size_w' ) );
$max_height = intval( get_option( 'thumbnail_size_h' ) );

// last chance thumbnail size defaults
if ( ! $max_width && ! $max_height ) {
  $max_width  = 128;
  $max_height = 96;
}

That single extra line makes such a difference when scanning code. Imagine trying to read a book with no paragraphs.

2 responses to “The need for whitespace”

  1. Hmm you have a decent point here John, However I am obsessive about website speed and optimizing, yep when coding a site its good but after I have finished testing it I obsessively compress everything.

    Have just stumbled on your blog as was just searching for similar domains to mine.

    Best,

    Phillip

    Like

    1. There’s a difference between source code and minified code, though. No one is reading your minified code.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: