Masonry imagesLoaded javascript error

Followed the same article and ran into the same issue; the author (Josh Pollock) posted a followup on his blog.

Essentially from WP 3.9, Masonry is there for you to use so all you need in functions.php is:

add_action( 'wp_enqueue_scripts', 'slug_masonry' );
function slug_masonry( ) {

    wp_enqueue_script('masonry'); // note this is not jQuery

}

and then initialize:

//set the container that Masonry will be inside of in a var
var container = document.querySelector('#masonry-loop');
//create empty var msnry
var msnry;
// initialize Masonry after all images have loaded
imagesLoaded( container, function() {
    msnry = new Masonry( container, {
        itemSelector: '.post'
    });
});