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.

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.

6 thoughts on “Enqueue Masonry in your WordPress theme

  1. Very cool – didn’t know it was there by default either. Were you using one of the built in default WP themes? Also, any idea how to apply masonry to post archives?

  2. Good find Jay, thanks for sharing. I was looking for a plugin for this.


  3. Love snippets, and loving your blog, themes, & plugins. :)

    I just “discovered” that masonry layout is the answer to a problem I’m having with my woocommerce products. Is there any way to apply this snippet to woocommerce product layouts?

    (I’ve been looking for a plugin or snippet to solve this problem. So far…Nuthin’.)

  4. It is updated to v3 in WordPress 3.9.

Leave a Reply

Your email address will not be published. Required fields are marked *