Js Media Query help

Hey there, I’ve added the masonry.js custom code to my page to get a masonry grid, but I want the code to not load/not affect the grid at mobile and lower. This was my attempt at doing this:

< script src=“https://cdnjs.cloudflare.com/ajax/libs/masonry/4.2.1/masonry.pkgd.min.js”>< /script>
< script>

window.addEventListener(‘resize’, function(){
if (window.innerWidth > 767).on("load", function() { (’.masonry’).masonry({
itemSelector: ‘.masonry-item’

< /script>

How can I fix this?

Read-only link