Title: Remove Useless script and css
Last modified: April 28, 2020

---

# Remove Useless script and css

 *  Resolved [beaversagency](https://wordpress.org/support/users/beaversagency/)
 * (@beaversagency)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/)
 * Hello,
 * How can I remove useless scripts and css files from every pages that don’t use
   a form ?
 * Thanks
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fremove-useless-script-and-css%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [Nobel Dahal](https://wordpress.org/support/users/nobeld/)
 * (@nobeld)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12743837)
 * Greetings [@beaversagency](https://wordpress.org/support/users/beaversagency/)
 * You can force specific scripts/styles to be dequeued. A sample code for doing
   so would be:
 *     ```
       // For styles
       add_action( 'wp_print_styles', 'dequeue_evf_styles' );
       function dequeue_evf_styles() {
           wp_dequeue_style( 'everest forms stylesheet id you wish to dequeue' );
           // ... 
       }
   
       // For scripts
       add_action( 'wp_print_scripts', 'dequeue_evf_script' );
       function dequeue_evf_script{
           wp_dequeue_style( 'everest forms javascript id you wish to dequeue' );
           // ... 
       }
       ```
   
 * Please note that this has to be done in a very controlled manner, with care so
   the de-queue don’t hamper everest forms from operating as intended. And quite
   often than not, the performance improvement you gain by having selectively remove
   essential css/js enqueues is almost always not worth the effort put into optimizing
   enqueues. I wish you all the best!
 *  Thread Starter [beaversagency](https://wordpress.org/support/users/beaversagency/)
 * (@beaversagency)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12743881)
 * Hi [@nobeld](https://wordpress.org/support/users/nobeld/) ,
 * Thank you for your answer, it’s what I needed 😉
 *  Thread Starter [beaversagency](https://wordpress.org/support/users/beaversagency/)
 * (@beaversagency)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12744245)
 * hi [@nobeld](https://wordpress.org/support/users/nobeld/) ,
 * There is no id for scripts. Only for stylesheet.
    So I don’t know what put into
   the function for scripts. Can you help please ?
 * Thanks
 *  [Nobel Dahal](https://wordpress.org/support/users/nobeld/)
 * (@nobeld)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12744592)
 * Greetings [@beaversagency](https://wordpress.org/support/users/beaversagency/)
 * For sure. Here are some that are the names of the registered scripts under frontend
   scripts:
 *     ```
       inputmask
       flatpickr
       mailcheck
       jquery-validate
       everest-forms
       everest-forms-text-limit
       everest-forms-ajax-submission
       ```
   
 * Do note that these may change as the everest forms potentially assimilates new
   features. In order to find out what they are from time to time, you’ll need to
   refer to the `EVF_Frontend_Scripts` class in `class-evf-frontend-scripts.php`.
 * Hope that helps, happy tinkering! 🙂
 *  Thread Starter [beaversagency](https://wordpress.org/support/users/beaversagency/)
 * (@beaversagency)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12745495)
 * Hi [@nobeld](https://wordpress.org/support/users/nobeld/) ,
 * I did what you tell me to do but it’s not working.
    Here what I test :
 *     ```
       add_action( 'wp_print_scripts', 'dequeue_evf_script' );
       function dequeue_evf_script() {
         wp_dequeue_style( 'inputmask' );
       }
       ```
   
 *     ```
       add_action( 'wp_print_scripts', 'dequeue_evf_script' );
       function dequeue_evf_script() {
         wp_dequeue_script( 'inputmask' );
       }
       ```
   
 * Can you help ?
 * FYI, everything is working for stylesheets 😉
 * Tks
    -  This reply was modified 6 years, 1 month ago by [beaversagency](https://wordpress.org/support/users/beaversagency/).
 *  [Nobel Dahal](https://wordpress.org/support/users/nobeld/)
 * (@nobeld)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12748846)
 * Greetings [@beaversagency](https://wordpress.org/support/users/beaversagency/)
 * I believe it’s because you have the same callback for 2 different added hooks.
 * Try something like
 *     ```
       add_action( 'wp_print_styles', 'dequeue_evf_STYLE' );
       function dequeue_evf_STYLE() {
         wp_dequeue_style( 'inputmask' );
       }
   
       add_action( 'wp_print_scripts', 'dequeue_evf_SCRIPT' );
       function dequeue_evf_SCRIPT() {
         wp_dequeue_script( 'inputmask' );
       }
       ```
   
 * Note that the functions should be different, as they both are supposed to do 
   2 different things, and they are supposed to be done at particular WordPress 
   events, namely 2 – printing styles, or printing scripts.
 * Also, do keep in mind that you might have to deregister the script as well, in
   extreme cases. `wp_deregister_script( string $handle );`, this should work out
   if you add it in the same function as the one where you dequeue evf scripts.
 *  Thread Starter [beaversagency](https://wordpress.org/support/users/beaversagency/)
 * (@beaversagency)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12749390)
 * Hi,
 * Yeah I know it. What I meant, it’s that I tested these 2 part of code separately
   and none works.
 * Only the style is removed by :
 *     ```
       function dequeue_evf_styles() {
           wp_dequeue_style('everest-forms-general');
           wp_dequeue_style('everest-forms-pro-frontend');
       }
       add_action('wp_print_styles', 'dequeue_evf_styles');
       ```
   
 * But not scripts :/
 * Tks
 *  [Nobel Dahal](https://wordpress.org/support/users/nobeld/)
 * (@nobeld)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12755303)
 * Greetings [@beaversagency](https://wordpress.org/support/users/beaversagency/)
 * `wp_deregister_script( string $handle );` should help you out in that.

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

The topic ‘Remove Useless script and css’ is closed to new replies.

 * ![](https://ps.w.org/everest-forms/assets/icon.svg?rev=2778675)
 * [Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder](https://wordpress.org/plugins/everest-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/everest-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/everest-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/everest-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/everest-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/everest-forms/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Nobel Dahal](https://wordpress.org/support/users/nobeld/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/remove-useless-script-and-css/#post-12755303)
 * Status: resolved