WT Masonry.js

WT Masonry.js

Masonry script that allows you to output images in the form of brickwork. The script is designed in Joomla 4+ WebAsset, which allows you to use it in any extensions of Joomla 4 and Joomla 5. This is a plugin for Joomla developers. It does not provide ready-to-use code.


What is Masonry?

Masonry is a JavaScript grid layout library. It works by placing elements in optimal position based on available vertical space, sort of like a mason fitting stones in a wall. You’ve probably seen it in use all over the Internet.

Enabling an asset in Joomla

$wa = Factory::getApplication()->getDocument()->getWebAssetManager(); 
$wa->useScript('wtmasonryjs.local'); // local file 
$wa->useScript('wtmasonryjs.remote'); // from CDN 
$wa->useScript('imagesloaded.local'); // imagesLoaded.js from local file 
$wa->useScript('imagesloaded.remote'); // imagesLoaded.js from CDN

After that, the local or from CDN masonry script will be included in the <head> of the Joomla page.

Also, the imagesLoaded imagesLoaded asset has been added to the plugin, which should be used with a large number of images.

Code example

An example from the official documentation of the script


<div class="grid">
  <div class="grid-item">...</div>
  <div class="grid-item grid-item--width2">...</div>
  <div class="grid-item">...</div>


All sizing of items is handled by your CSS.

.grid-item { width: 200px; }
.grid-item--width2 { width: 400px; }

Initialize with jQuery

  // options
  itemSelector: '.grid-item',
  columnWidth: 200

Initialize with Vanilla JavaScript

var elem = document.querySelector('.grid');
var msnry = new Masonry( elem, {
  // options
  itemSelector: '.grid-item',
  columnWidth: 200

// element argument can be a selector string
//   for an individual element
var msnry = new Masonry( '.grid', {
  // options

Connecting imagesLoaded

This script initializes masonry again after loading the next image. This creates a dynamic addition of images to the brickwork.

Initialize with jQuery

// init Masonry
var $grid = $('.grid').masonry({
  // options...
// layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {

Initialize with Vanilla JavaScript

document.addEventListener('DOMContentLoaded',() => {
    const masonryGrid = document.getElementById('masonry-test');
    var msnry = new Masonry(masonryGrid, {
        itemSelector: '.grid-item',
        columnWidth: 200,
        percentPosition: true

    imagesLoaded( masonryGrid ).on( 'progress', function() {
        // layout Masonry after each image loads




Extension type:
Joomla version:
4.3.4, 5.0.0

What's new

Bug fixes

Bug fixes in the plugin code

Joomla 5 ready

Successfully tested working with Joomla 5

WebTolk Joomla Extensions

70 Extensions
10 Categories
302 Versions released
Cart is empty