Loading JS in functions.php is resulting in 404 error.

[ad_1]

I am new to javascript but I’m currently trying to build a responsive image gallery in wordpress with my custom template. I have used this function to load my js file onto my page and it shows in developer tools that it has loads but has an error 404 not found.

My function to load the js script is

function load_js_assets() {
if(is_page(57)){
wp_enqueue_script(‘my-js’, ‘photo.js’, array(‘jquery’), ”, false       
);   
}
}

add_action(‘wp_enqueue_scripts’, ‘load_js_assets’);

​

That is the correct the file path (i removed it from the js folder just in case i was doing it wrong).

Any help would be greatly appreciated thank you.

[ad_2]
1 Comment
  1. Look at how your theme enqueues its JS files. I can guarantee you it is not using the naked file name like you are.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer