Title: Causes wp_enqueue_ errors
Last modified: August 22, 2016

---

# Causes wp_enqueue_ errors

 *  Resolved [wpni](https://wordpress.org/support/users/wpni/)
 * (@wpni)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/causes-wp_enqueue_-errors/)
 * Causes wp_enqueue_script & wp_enqueue_style errors.
    Tested with several themes,
   including Twenty Twelve & Twenty Eleven All other plugins disabled. Also removed&
   re-installed.
 * 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 Debugging in WordPress for more information.(
   This message was added in version 3.3.) in /Applications/MAMP/htdocs/THESITE/
   wp-includes/functions.php on line 3245
 * Notice: wp_enqueue_style 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 Debugging in WordPress for more information.(
   This message was added in version 3.3.) in /Applications/MAMP/htdocs/THESITE/
   wp-includes/functions.php on line 3245
 * [https://wordpress.org/plugins/x-scroll-to-top-responsive/](https://wordpress.org/plugins/x-scroll-to-top-responsive/)

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

 *  Plugin Author [Md Jahidul Islam](https://wordpress.org/support/users/md-jahidul-islam/)
 * (@md-jahidul-islam)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/causes-wp_enqueue_-errors/#post-5219241)
 * I think problem with your WordPress. Because I check it again and its working
   very well. You can try this any other WordPress site.
 *  [perpetual.design](https://wordpress.org/support/users/perpetualdesign/)
 * (@perpetualdesign)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/causes-wp_enqueue_-errors/#post-5219480)
 * > 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 Debugging in WordPress for more 
   > information. (This message was added in version 3.3.) in C:\xampp\htdocs\mooresvilleglass.
   > local\wp-includes\functions.php on line 3547
   > Notice: wp_enqueue_style 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 Debugging in WordPress for more 
   > information. (This message was added in version 3.3.) in C:\xampp\htdocs\mooresvilleglass.
   > local\wp-includes\functions.php on line 3547
 * I have the same issue. It’s just a PHP Notice, and by no means a content killing
   error on the frontend of the Dashboard backend. Deactivating this plugin makes
   the notice go away (this is all with WordPress Debug on, of course). Looking 
   over the plugin code I can’t seem to pinpoint what would cause this…
 * And by the way, I am using WordPress 4.1.1 and the latest plugin to date of this
   post.
 *  [tnchuntic](https://wordpress.org/support/users/tnchuntic/)
 * (@tnchuntic)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/causes-wp_enqueue_-errors/#post-5219484)
 * Hi Jahidul,
 * Good day
 * The error is cause by the enqueue script and style it should be wrap inside function
   and triggered by add_action. You will see the error when you enable the WP_DEBUG
   to TRUE.
 * See below code **OLD**
 *     ```
       wp_enqueue_script('x-jquery-easing', X_PLUGIN_URL.'js/jquery.easing.min.js', array('jquery'));
       wp_enqueue_script('x-jquery-main-scroll-up', X_PLUGIN_URL.'js/jquery.scrollUp.min.js', array('jquery'));
       wp_enqueue_script('x-jquery-active', X_PLUGIN_URL.'js/active.js', array('jquery'));
       wp_enqueue_style( 'wp-color-picker' );
       wp_enqueue_script( 'my-script-handle', plugins_url('js/my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
   
       wp_enqueue_style('x-scroll-plugin-css', X_PLUGIN_URL.'css/custom.css');
       wp_enqueue_style('x-scroll-plugin-fontello-css', X_PLUGIN_URL.'css/fontello.css');
       ```
   
 * Change to **NEW**
 *     ```
       function add_x_scroll_style() {
           if ($GLOBALS['pagenow'] != 'wp-login.php' && !is_admin()) {
               wp_enqueue_style('x-scroll-plugin-css', X_PLUGIN_URL.'css/custom.css');
               wp_enqueue_style('x-scroll-plugin-fontello-css', X_PLUGIN_URL.'css/fontello.css');
           }
       }
       add_action('wp_enqueue_scripts', 'add_x_scroll_style');
   
       function add_x_scroll_script() {
           if ($GLOBALS['pagenow'] != 'wp-login.php' && !is_admin()) {
               wp_enqueue_script('x-jquery-easing', X_PLUGIN_URL.'js/jquery.easing.min.js', array('jquery'));
               wp_enqueue_script('x-jquery-main-scroll-up', X_PLUGIN_URL.'js/jquery.scrollUp.min.js', array('jquery'));
               wp_enqueue_script('x-jquery-active', X_PLUGIN_URL.'js/active.js', array('jquery'));
   
           }
       }
       add_action('wp_enqueue_scripts', 'add_x_scroll_script');
   
       function add_admin_x_scroll_scripts() {
   
           //Register color picker script
           wp_enqueue_style( 'wp-color-picker' );
   
           wp_enqueue_script( 'my-script-handle', plugins_url('js/my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
       }
   
       add_action('admin_enqueue_scripts', 'add_admin_x_scroll_scripts');
       ```
   
 * Hope this helps and if your satisfied with the code kindly update your plugin.
 * Thanks

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

The topic ‘Causes wp_enqueue_ errors’ is closed to new replies.

 * ![](https://ps.w.org/x-scroll-to-top-responsive/assets/icon-256x256.jpg?rev=2057600)
 * [X-Scroll To Top - Responsive](https://wordpress.org/plugins/x-scroll-to-top-responsive/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/x-scroll-to-top-responsive/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/x-scroll-to-top-responsive/)
 * [Active Topics](https://wordpress.org/support/plugin/x-scroll-to-top-responsive/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/x-scroll-to-top-responsive/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/x-scroll-to-top-responsive/reviews/)

 * 3 replies
 * 4 participants
 * Last reply from: [tnchuntic](https://wordpress.org/support/users/tnchuntic/)
 * Last activity: [10 years, 12 months ago](https://wordpress.org/support/topic/causes-wp_enqueue_-errors/#post-5219484)
 * Status: resolved