I'm trying to get the jQuery Masonry plugin to work on a site. I've updated my template files to get the proper classes where the plugin needs them. Then I enqueued my scripts like this:
function masonry_scripts() {
wp_enqueue_script('masonry');
wp_enqueue_script( 'masonry-script', get_template_directory_uri() . '/assets/js/masonry-script.js', array(), false, true );
}
add_action( 'wp_enqueue_scripts', 'masonry_scripts' );
The masonry script is loading properly, but the masonry-script.js file doesn't. I get the following error in the console:
The script from “.../assets/js/masonry-script.js?ver=5.1.1” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.[Learn More] Loading failed for the with source “http://thewallmarket.local/wp-content/themes/storefront/assets/js/masonry-script.js?ver=5.1.1”.
Unfortunately, I can't provide a link to the site as it is developed locally.
What is causing this problem? How can I solve it?