Title: question about wp_enqueue_script
Last modified: August 19, 2016

---

# question about wp_enqueue_script

 *  Resolved [charlesolaes](https://wordpress.org/support/users/charlesolaes/)
 * (@charlesolaes)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/)
 * Is there a way to specify which scripts should load on which page using the enqueue
   script function? I noticed that conditional tags like is_home() or is_page() 
   doesn’t get called when calling on the action hook ‘init’. I’m trying to avoid
   called the script manually, ex `echo "<script scr='myscript.js'></script>";` 
   Since it has a chance of breaking some plugins. Is it possible to use something
   like query vars to determine which page I’m on in order to use wp_enqueue_script()?
 * PS: I have $infooter = true on the wp_enqueue_script() arguments.
 * Thanks

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/#post-2033948)
 * Use the conditional immediately before the wp_enqueue call.
 *  Thread Starter [charlesolaes](https://wordpress.org/support/users/charlesolaes/)
 * (@charlesolaes)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/#post-2034015)
 * cool, but it’s still loading scripts everywhere. here’s the code I’m using
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/#post-2034016)
 * Conditionals such as `is_home()` and `is_page()` are not yet available when the`
   init` hook is fired.
 * Try hooking into `wp_head` instead.
 *  Thread Starter [charlesolaes](https://wordpress.org/support/users/charlesolaes/)
 * (@charlesolaes)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/#post-2034030)
 * Thanks for the suggestion, but I tried changing the add_action(‘init’) to wp_head
   but the scripts doesn’t seem to load at all. will wp_enqueue_script work outside
   the init action hook?
 *  [Chip Bennett](https://wordpress.org/support/users/chipbennett/)
 * (@chipbennett)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/#post-2034031)
 * Have you tried the `wp_enqueue_scripts` hook?
 *  Thread Starter [charlesolaes](https://wordpress.org/support/users/charlesolaes/)
 * (@charlesolaes)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/#post-2034042)
 * oh cool, I wasn’t aware that wp_enqueue_scripts could be used as a hook, thanks
   a bunch, it’s working now and I learned something new. thanks again

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

The topic ‘question about wp_enqueue_script’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [charlesolaes](https://wordpress.org/support/users/charlesolaes/)
 * Last activity: [14 years, 12 months ago](https://wordpress.org/support/topic/question-about-wp_enqueue_script-1/#post-2034042)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
