Create Fast Masonry Grid Layouts with Bricks.js

It’s always been flattering elementary to create grids with jQuery, regulating plugins and giveaway tutorials from developers.

However, masonry grids are worse to build, given they don’t fit uniformly opposite a page. You’ll have fixed-size widths for columns though a item heights can change wildly.

To make a pixel-perfect masonry grid we need a plugin such as Bricks.js.

This plugin is totally open-source and ridiculously fast. It’ll render a grid in reduction than half a second, even with dozens of equipment on a page.

Most people commend masonry grids from Pinterest given they popularized a layout. But, it has given grown to be used in many other websites, too.

To get started with Bricks.js, you’ll need some content and a default page layout. You implement a plugin right from npm or by GitHub if that’s easier.

With a initial setup, we pass three specific parameters:

  1. Container – a DOM enclosure element for a grid
  2. Packed – an attribute that determines how a equipment upsurge in a grid
  3. Sizes – an array of widths and gutters, tangible in pixels

The plugin uses all these values to automate a masonry grid from scratch.

And, we can even use it for infinite loading if we wish masonry grids that work usually like Pinterest.

Bricks.js make-up jquery plugin masonryBricks.js make-up jquery plugin masonry

Check out a demo page for an interactive grid that we can change for testing. You define a sum series of elements and it’ll automate a routine while displaying a sum digest time.

For example, we tested a grid with 500 elements and it usually took 13 milliseconds to complete. This doesn’t cause in a time for all 500 images to load, though 13 ms for an auto-generated grid is really impressive.

Get started yourself by downloading a files from GitHub and following a implement instructions. This might feel treacherous during initial though a some-more we fondle with it a easier it is to set up.

Add Comment