WordPress wp_enqueue_script not loading up on Front-End

I’m currently loading up 3 scripts using the exact same method. However 2 of them are working and the other isn’t. I’ve checked the code multiple times for an error but got nothing. I don’t understand why the 3rd script won’t load.

public function scripts() {
wp_register_script( 
     'global', 
     get_template_directory_uri() . '/assets/js/global.min.js', 
     array( 'jquery' ),
     $version, 
     true
);
wp_enqueue_script( 'global' );

Then this is hooked in like:

add_action( 'wp_enqueue_scripts', array( $this, 'scripts' ) );

This works perfectly fine.
Then I add this next function and it doesn’t load:

public function map_scripts() {

global $version;

wp_register_script( 
     'map',
     get_template_directory_uri() . '/assets/js/map.min.js', 
     array( 'jquery' ), 
     $version, 
     true 
);
wp_enqueue_script( 'map' );

This, again, is hooked into the same construct function as the ‘global’ like:

add_action( 'wp_enqueue_scripts', array( $this, 'map_scripts' ) );

I’ve tried moving the ‘map’ script into the same public function as the ‘global’ and it still doesn’t load.

Does anyone have any clues?

Read more here: WordPress wp_enqueue_script not loading up on Front-End

Leave a Reply

Your email address will not be published. Required fields are marked *