Regarding the WordPress Version of Masonry
Posted February 20th, 2014 at 8:00am by Dan Birlew in Blog. Comments Off on Regarding the WordPress Version of Masonry
I soon determined why he’d had these problems: he hadn’t enqueued the WordPress version of Masonry at all, he’d done a head element script-link directly to the file at David DeSandro’s site.
So let me set the record straight: the version of Masonry that is included in the WordPress download package is an older version. Masonry 2.1.05 is what is included in WordPress, whereas the current library available is 3.1.4. If you link to or enqueue this version of Masonry in your theme or plugin then yes, there will be substantial differences.
Live-linking to any library is a bad idea. If the library is updated then the settings you scripted into your site may become obsolete due to a new release. Your site could be broken for a few hours or even days, if that’s how rarely you visit.
Bad enough is that WordPress always updates to the (almost) latest version of jQuery as this renders a lot of themes and plugins obsolete, forcing us web developers to update our themes and plugins and also forcing our users to download these updates in order to keep your WordPress sites working. But we can hardly expect WordPress to keep using jQuery 1.7.2 infinitely and render itself technically backwards, now can we?
The reason Masonry is even a part of WordPress is that it was used in the TwentyThirteen theme’s footer to align the widgets in nice columns regardless of list size. They enqueued the version of the script they needed to accomplish this task alone, and then they were done. Unless Masonry is used somehow somewhere else in the backend in a future update, I sincerely doubt that the Masonry script will get an update in upcoming WordPress packages.
My presentations about Masonry have been about how to use the version that is INCLUDED IN WordPress; hence I give these presentations at WordPress related meet-ups and conferences. Newer versions of Masonry are quite nice, however. For example, it already animates on browser resize, as my friend pointed out. It automatically centers the selected items within the container element, without having to add a custom layout. imagesLoaded is indeed missing, but only because Masonry is so much larger than it was before: almost three times larger, in fact. Using this version instead of the version included in WordPress is highly recommended; you need only download it, save it among your theme files and enqueue via direct link, as instructed here.