Hi Selezen,
We did have a look at this a while ago and were thinking along the same line. However, in order to reduce the size, we decided to just use as minimal javascript as possible and let the owner to decide which script best suits the purpose.
The entire layout can be replaced completely (by copying it to the /web/{your-site-name}/themes/{your-theme-name}/macros/gallery/view.gallery.template.php .. there's also a sample in /system/macros/gallery/sample.view.gallery.template.php and you can adjust it for any javascript masonry library like in
https://morioh.com/p/6dddf25fead3
Hope this helps ...