How to make Isotope and WordPress work together?

The Isotope documentation about ImagesLoaded suggest two methods for this. I generally use the second one, which means: initializing Isotope and trigger layout after the images have been loaded. In my experience this works better, not that I have facts to proof it. Aside from that, I have it running this way successfully on a bunch of sites.

The javascript file looks like this:

jQuery(document).ready(function($) {

    var $container = $('#your-id');

    $container.isotope({
        layoutMode: 'masonry',
        itemSelector : '.your-class',
        masonry: {
            columnWidth: 200,
        }
    });

    $container.imagesLoaded( function() {
        $container.isotope('layout');
    });
});