Enqueue Masonry in your WordPress theme

Strap yourselves in, it’s time for a ground-breaking WordPress snippet. </sarcasm>

Today I wanted to include a popular jQuery plugin in a theme I was building so decided to check if the script was bundled in WordPress core. Turns out it wasn’t, but I noticed another script which is, that I didn’t expect; Masonry.

Masonry is a really fun script for arranging blocks of content based on available vertical space.

So that means you can call masonry in your plugin / theme without actually including the file in your assets.

https://gist.github.com/jameskoster/6922224

Unfortunately it’s a pretty old version (2.1.05) but there’s a ticket on Trac reporting that issue. There’s no milestone set, but hopefully we’ll see masonry updated soon.