Script for initializing JQuery Masonry for WordPress

This executes, when the DOM has been constructed, before all content has been loaded

$(document).ready(function(){ ... });
$(function(){...}); // short form

This executes, when all content has been loaded

$(window).load(function(){ ... });

This executes immediately, when it is first encountered by the browser

(function(){ ... })();

The latter is known as a self-executing anonymous function, which is very handy, but not here, because no content or not the right content may have been loaded when it self-executes.