Title: wp_enqueue_script was called incorrectly
Last modified: May 16, 2018

---

# wp_enqueue_script was called incorrectly

 *  Resolved [idealbrandon](https://wordpress.org/support/users/idealbrandon/)
 * (@idealbrandon)
 * [8 years ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-15/)
 * I’ve spent the better part of four hours trying to solve this freaking problem
   and am losing my mind.
 * [16-May-2018 20:57:32 UTC] PHP Notice: wp_enqueue_script was called
    **incorrectly**.
   Scripts and styles should not be registered or enqueued until the `wp_enqueue_scripts`,`
   admin_enqueue_scripts`, or `login_enqueue_scripts` hooks. Please see <a href=”
   [https://codex.wordpress.org/Debugging_in_WordPress”>Debugging](https://codex.wordpress.org/Debugging_in_WordPress”>Debugging)
   in WordPress for more information. (This message was added in version 3.3.0.)
   in ../html/wp-includes/functions.php on line 4147 I’ve never encountered this
   error before, and have been a WordPress developer for years. I’ve been working
   on this theme for months, and this error suddenly started showing up today. No
   plugin / Core updates. In fact, no changes to the way styles/scripts are enqueued.
 * This error only shows on the backend, and it logs to the debug file constantly,
   even without page refreshes.
 * I’ve done the usual and disabled all plugins… Error still appears. I removed 
   all plugins from plugins directory… Error still appears. I’ve gone through my
   theme and literally removed every single reference to wp_enqueue_script and the
   error STILL appears.
 * I literally have no styles and no scripts being loaded (correctly or incorrectly),
   no reference to wp_enqueue_script, or any reference to any of the acceptable 
   hooks, and this error still shows up.
 * If I disable the theme, all is well. What on earth could be the problem? Is there
   any way to see what script is actually throwing the error?

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

 *  [JNashHawkins](https://wordpress.org/support/users/jnashhawkins/)
 * (@jnashhawkins)
 * [8 years ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-15/#post-10288346)
 * Sounds like a rogue function in the theme possibly.
 * Did you look at the functions php file?
 *  Thread Starter [idealbrandon](https://wordpress.org/support/users/idealbrandon/)
 * (@idealbrandon)
 * [8 years ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-15/#post-10288576)
 * Yes. As I said, I’ve completely removed every single reference to and script 
   or style and any enqueue, and I’m still getting this error. No plugins loaded,
   and the theme is 100% coded by me. I’m used a global search and replace to ensure
   that I’m loading nothing, and have even checked the dev tools in the admin to
   see if there is anything random been loaded that I was (somehow) unaware of. 
   Nothing.
 *  Thread Starter [idealbrandon](https://wordpress.org/support/users/idealbrandon/)
 * (@idealbrandon)
 * [8 years ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-15/#post-10288687)
 * UGH.
 * I solved this. I’m an idiot. I had a file in my theme named admin.php that was
   setting up wp-admin handlers and the like for a portion of my application.
 * I was including this via `include_once( 'admin.php' )` from its parent file, 
   and apparently that was calling the main wp-core admin.php file. So yeah. Hours
   of debugging because I didn’t specify an absolute path. smh.
 *  [JNashHawkins](https://wordpress.org/support/users/jnashhawkins/)
 * (@jnashhawkins)
 * [8 years ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-15/#post-10288889)
 * Glad you found it!

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

The topic ‘wp_enqueue_script was called incorrectly’ is closed to new replies.

## Tags

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

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 4 replies
 * 2 participants
 * Last reply from: [JNashHawkins](https://wordpress.org/support/users/jnashhawkins/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/wp_enqueue_script-was-called-incorrectly-15/#post-10288889)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
