Try including the full path to the resource files, as per the instructions on the Masonry getting started documentation:
Include the Masonry script in your site.
<script src="/path/to/masonry.pkgd.min.js"></script>
For example:
<script src="/desktopmodules/com.demo.masonry/Scripts/jquery.infinitescroll.min.js"></script>
<script src="/desktopmodules/com.demo.masonry/Scripts/masonry.pkgd.js"></script>
<script src="/desktopmodules/com.demo.masonry/Scripts/imagesloaded.js"></script>