This is an awesome js library: http://packery.metafizzy.co/