Title: Cannot Enqueue Scripts?
Last modified: August 30, 2016

---

# Cannot Enqueue Scripts?

 *  [evos](https://wordpress.org/support/users/evos/)
 * (@evos)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/cannot-enqueue-scripts/)
 * Hi all,
 * I’m attempting to load a javascript file (eventually will be multiple js and 
   css) into the header of the site. As far as I can tell, it should be a simple
   process of defining a custom function in functions.php and using add_action()
   to register it?
 * Here is my code (in functions.php):
 *     ```
       function load_scripts_and_styles() {
       	$root = get_theme_root_uri();
       	$dir = $root . 'evos/js/functions/functions.js';
   
       	wp_enqueue_script('functions', $dir);
       }
       add_action( 'wp_enqueue_scripts' , 'load_scripts_and_styles' );
       ```
   
 * I cannot understand why this isn’t working, I would of thought it would be simple
   or at the least I would get some kind of error?
 * Thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * (@rajeshsoni)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/cannot-enqueue-scripts/#post-6416046)
 * Have you tried displaying the $dir variable after it’s set?
 *  Thread Starter [evos](https://wordpress.org/support/users/evos/)
 * (@evos)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/cannot-enqueue-scripts/#post-6416059)
 * You mean simply echo it out?
 * $dir contains the correct filepath but I have only been able to test this outside
   of load_scripts_and_styles().
 * What I mean to say is the function doesn’t seem to get called at all.. even a
   simple echo isn’t displayed which makes me think it’s a problem with the add_action()
   but I’m just taking blind stabs in the dark right now!
 *  [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * (@rajeshsoni)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/cannot-enqueue-scripts/#post-6416150)
 * Can you post the entire functions.php on pastie.org and share the URL here?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Cannot Enqueue Scripts?’ is closed to new replies.

## Tags

 * [enqueue](https://wordpress.org/support/topic-tag/enqueue/)
 * [headache](https://wordpress.org/support/topic-tag/headache/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Rajesh Soni](https://wordpress.org/support/users/rajeshsoni/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/cannot-enqueue-scripts/#post-6416150)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
