1. Home
  2. Knowledge Base
  3. How to Dequeue Unnecessary Scripts and Styles

How to Dequeue Unnecessary Scripts and Styles

Introduction

Sometimes, plugins or themes load scripts and styles on the WordPress login page that are not required. These extra assets can affect performance or cause styling conflicts. You can prevent specific scripts or styles from loading by dequeuing them using a small custom function. This guide explains how to safely dequeue unnecessary scripts and styles.

Custom Workaround

Before proceeding, make sure you have a complete site backup.

  1. Go to Appearance > Theme Editor in your WordPress dashboard.
  2. Under Select theme to edit, choose your active theme (preferably a BuddyBoss Child Theme), then click Select.
  3. From the Theme Files list, open Theme Functions (functions.php).
  4. Add the following code just before the closing PHP tag (?>):
function tirarScripts() {

    wp_dequeue_style( 'slate-js' );

}

add_action( 'login_enqueue_scripts', 'tirarScripts' );
  1. Click Update File to save the changes.

This will prevent the specified style or script from loading on the WordPress login page.

Note:
– Make sure the handle (slate-js in this example) exactly matches the script or style ID registered by the theme or plugin. If you’re unsure of the correct handle, you may need to inspect the page source or contact the plugin or theme author for confirmation.

– Modifications are typically considered custom work, but we are making an exception in this case. Please review the BuddyBoss Support Policy.

Troubleshooting and FAQs

Q: How do I find the correct script or style handle?
A: You can inspect the login page source code and look for the id attribute on <link> or <script> tags, or ask the plugin/theme author for the correct handle name.

Q: Will this affect other pages on my site?
A: No. This code only affects the WordPress login page because it uses the login_enqueue_scripts hook.

Q: How do I revert this change?
A: Remove the added code from functions.php and save the file.

Was this article helpful?

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

This field is for validation purposes and should be left unchanged.
This field is hidden when viewing the form

To speak to our Agency consultant, fill in the form found at our Contact Page.