Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How WordPress Plugins Affect Your Site’s Load Time

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How WordPress Plugins Affect Your Site’s Load Time

Have you heard from developers that the more plugins you use, the slower your WordPress site gets? Well that is partially true. Some plugins add just a small query which has little to no impact on your site’s load time. Where as other plugins add jQuery and CSS on each page load (in your site’s <head></head> area). So for example if each plugin adds one jQuery file and one CSS stylesheet and you have 8 plugins like that, you just added 16 HTTP Requests. This can get really out of control when plugins start adding more than one stylesheet or jQuery files. In this article, we will show you how you can still use all the WordPress plugins you want without the additional HTTP Requests.

Note: We recommend that you at least know some PHP before diving into this tutorial.

Our Goal: Disable all Additional Scripts and Stylesheets that plugins add on each page load.

Wait a minute, Why do these plugins add these scripts and styles? Isn’t it necessary for the plugins to function properly? Glad you asked. Most likely those CSS and JavaScript codes are important to the functionality of the plugin, but we will remove it anyways to have more control on our WordPress site and make it run faster. By disabling the CSS files and JavaScripts, we can:

But, we want to take control of these files and make our sites run faster. Disabling these scripts and styles will allow us to do a few things:

  • Combine multiple files into a single file (Sprite Technique).
  • Load the files only on the pages we’re using the script or style.

Disable Scripts and Styles in WordPress

The best part about WordPress is that it has a built-in system that allows us to deregister scripts and styles that are added by the plugins. The “bad part” in this situation about WordPress is that it is open-source, so the plugins are created by people in the community (Expert developers and new developers). This means that not all plugins use the correct methods for loading scripts and styles which makes our job harder. The correct method is by registering the stylesheet or scripts with the following WordPress functions: wp_enqueue_script() and wp_enqueue_style(). If your plugin author isn’t using these functions, then send them a kind email asking them to update the plugin. This is not hard, it is just a matter of a learning curve.

To figure out what scripts or styles you want to disable, you might have to dig deeper and gets your hand dirty. This means looking in the code of your plugins.

Disabling CSS (Stylesheets)

In this example, we will use a plugin called Cleaner Gallery which adds its own CSS file on each page load. First, you have to check whether the plugin is using the correct method for adding stylesheets. To do so, you would need to open the plugin file: gallery.php (for this plugin). In there, you should run a search for “wp_enqueue_style”. You will find results like this:

wp_enqueue_style( 'cleaner-gallery', CLEANER_GALLERY_URL . 'cleaner-gallery.css', false, 0.8, 'all' );

Now you know the name of the handle for the style which is ‘cleaner-gallery’. Then you would need to open your theme’s functions.php file and add the following code:

    add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
    function my_deregister_styles() {
    wp_deregister_style( 'cleaner-gallery' );

You can deregister as many style handles you want within this function. So if you have more than one plugin to deregister the stylesheet for, you would do it like this:

    add_action( 'wp_print_styles', 'my_deregister_styles', 100 );

    function my_deregister_styles() {
    wp_deregister_style( 'cleaner-gallery' );
    wp_deregister_style( 'Plugin Style Handle' );
    wp_deregister_style( 'Plugin Style Handle' );

Now once you have removed the stylesheets from being loaded on every page, it will affect plugin’s functionality. For example, your gallery will be BROKEN in terms of styling and organization. To fix this, you should open your theme’s style.css file, and all the way at the bottom paste the CSS codes from the plugin(s). In our example, we removed cleaner gallery stylesheet from loading, so you will now open cleaner-gallery.css which can be found in that plugin’s folder. Copy the code and paste it in your theme’s style.css file. This way not only that you would be able to customize the display of your gallery, but you will also reduce one HTTP request.

The Ideal Way

A plugin known as WP-PageNavi gives its users an option to remove the stylesheet from the Dashboard Settings Page.

WP-PageNavi Options

Most of the time, you would need to customize the display of this plugin to match your site’s color scheme. Because of that most users, ended up pasting the codes on their style.css anyways. Now the plugin author lets you deregister the stylesheet with a simple check box.

We are hoping that more and more plugin developers follow this step to make the job easier :)

Disabling JavaScripts

Some plugins also add the JavaSscript on the page for the sake of functionality. In our example, we will use the plugin Contact Form 7.

You will need to dig deeper in the Plugin files to find the script handle just like we did with the Styles. For this plugin, the script handle is ‘contact-form-7’. You will need to copy and paste the function below in your theme’s functions.php file:

    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

    function my_deregister_javascript() {
    wp_deregister_script( 'contact-form-7' );

You can deregister multiple scripts within one function if you so desire. Once you remove the JavaScript, it will certainly affect the plugin’s functionality. You can combine JavaScripts together, but sometimes it does not work, so you must know what you are doing. You can learn from Trial and Error (like a lot of us do), but we recommend you do not do that on a live site.

Load Scripts Only on Specific Pages

Lets say that you know the Contact Form Script is necessary, and you cannot merge it with other scripts for some reason. You can load it only on the contact page if you so desire with the following function:

    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

    function my_deregister_javascript() {
    if ( !is_page('Contact') ) {
    wp_deregister_script( 'contact-form-7' );

By doing this, you will save the unnecessary script load on all the other pages that does not have the Contact Form. This is an extremely useful technique to improve site’s load time. You can use other parameters such as !is_single etc.

If you are using a lot of plugins on your site, we recommend that you open FireFox and View the Source file of your main page (Ctril + U). Then look above this area </head> and see how many plugins are adding HTTP Requests such as stylesheets and JavaScripts. Also install the YSlow Plugin on Firefox to see what can be fixed and what is your current Site Grade. Follow this tutorial above, and report back to us how much did you improve your site grade by. Have fun.

Additional Resources

Justin Tadlock
WordPress Codex: Scripts / Styles

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Audrey W says:

    I’m trying to deregister the following style from the Music Seller plugin with no luck:

    wp_enqueue_style(‘ms-mediacore-style’, plugin_dir_url(__FILE__).’ms-styles/mediaelementplayer.min.css’);

    Do I need to do something different to account for the * plugin_dir_url(__FILE__) * part of the file name?

  2. WebNashr says:

    Is there a plugin for the job? I mean deregistering styles and scripts?

  3. Cassandra Verique says:

    Hi there, I want to know whether there is any way to let’s say “Naturalize a Complete Install” I mean. Take all the functionality from a complete site with all plugins loaded and recreate this site as a single install. Is this possible? How is such a process called?

  4. Himanshu Goel says:

    Do including multiple functions.php file in a single theme functions.php file also make requests or they are simply merged together and runs as a single file…

    if so, then it may be also true that using a custom plugin as you described in your articles runs with single .php file won’t be making additional requests…

  5. Amanda Mays says:

    I followed this to deregister stylesheets from plugins for my site but when I test it at it still shows them having made separate HTTP requests and show a 404 error for each css file that I deleted after having copied and pasted the css into one style.css. What gives?

    Any help would be appreciated!


  6. salem says:

    This Is Best wordpress tutorial I Ever read . you short a lot coding and editing plugins php files to me .
    It was nightmare when I see most of my site load time spending in Plugins CSS and Javascript files .
    I thing my site will boost up higher from now on .
    Thanks again for this great help .

  7. Jose David Garcia Llanos says:

    Thanks for sharing this post with everyone else, I also use the methods mentioned in this article, I was amazed by how many plugins weren’t registering and en-queuing their js/css files.

    I use WP minify nowdays with Super cache.

  8. Jimmy Pena says:

    The guy who wrote Contact Form 7 already has an explanation on his site about how to conditionally load CSS and JS on contact form pages:

    • wpbeginner says:

      @Jimmy Pena Yes and we have the method defined above…

      • Jimmy Pena says:

        @wpbeginner Your function is optimistic (or is it pessimistic, I forget the difference). Since the contact page is only one of many pages found on a site, what you should be doing is:

        1. Deregister the script by default
        2. Check if the page is the contact page, and if so,
        3. register (enqueue?) the script

        For example if your site has 100 pages and 1 page has the Contact form, you are entering the If statement 99 times. If you write it like this:

        add_action( ‘wp_print_scripts’, ‘my_deregister_javascript’, 100 );
        function my_deregister_javascript() {
        // automatically deregister the wpcf7 js script
        wp_deregister_script( ‘contact-form-7’ );
        if ( is_page(‘Contact’) ) {
        // load the script only on the contact page
        wp_enqueue_script( ‘contact-form-7’ );

        then you only enter the If statement on the actual Contact page. In other words, since our purpose is to eliminate script loading on non-Contact pages, we should be assuming that the script is unwanted except where we specifically want it to load.

  9. rochdaniel says:

    The only issue is with plugin is when some of them are hardcoding CSS or JS ine the header, without using register _script or register_style. In those cases, we have to correct the plugin (and so on with each update…)

  10. sonya lynn says:

    Can you do multiple “ifs” and how? like…IF it’s a contact page, load contact code, and If it’s a store page, load store code, etc..

    I have a lot of plugins installed!

    • wpbeginner says:

      @sonya lynn You can use:if (!is_page(‘Contact’)) { Do this } elseif (!is_page(‘Store’)) { Do this } etc…

      • Dudestein says:

        @wpbeginner@sonya lynn Noooo, use a case statement, not a bunch of IFs.

        switch ($POST->post_name) {

        case ‘contact’:

        [do contact page stuff here]


        case ‘about-us’:

        [do about-us page stuff here]



        [do whatever should happen if it doesnt match any of the other rules here]



  11. Crysislevel says:

    i use 22 plugins on my site….also thanx for this as i can reduce my site loading time remarkably by truncating additional http requests! :)

  12. dbrabyn says:

    nope, none of this is working for me

  13. dbrabyn says:

    ah! is_user_logged_in ?

  14. dbrabyn says:

    I just tried: if (!is_page(‘Whatever’) || !is_admin()) but it didn’t work. I don’t see a “is_loggedin” tag

  15. wpbeginner says:

    @dbrabyn Yes there is. Refer to the WordPress codex for conditional tags. You can do it so the script only loads if the user is logged in. If it is admin panel etc.

  16. dbrabyn says:

    Great tips as always.

    I disabled thickbox js and css from all pages that didn’t need it but then realized it is needed for the admin pages.

    Is there a way to specify if !is_page(‘whatever’ and ‘a generic ID for all admin pages’) ? In other words disable scripts & css from all pages except the relevant ones AND all admin pages?

  17. kannapiran says:

    Won’t the addition of plugin codes, styles on to the original style sheets, function files affect the WP up-gradation. For each theme or different site we need to do it separately. When we handle multiple sites won’t it be tough to code each site differently rather than adding a plugin and just activating it.

    • Editorial Staff says:

      Sure, it is not easy, but is it worth (certainly if you care about your site’s performance). Adding the plugin style codes in your css file may increase the file size a bit, but it decreases HTTP queries. Second, a lot of plugin CSS are not minified. So you are better of doing it this way.

      What split great sites from good sites is the laziness of good sites ;)

  18. Bronson says:

    Thanks for this solid and actionable advice.

    Plugins are great, but the extra fat added in the form of JS and CSS can be a nightmare to optimise – busy doing just that for someone right now.

    I would really like to be able to load specific stuff for specific pages eventually and then be left to focus on optimising the common, shared stuff.

  19. Mohd Isa says:

    this is awesome, i need reduce my plugin now. so many css and js. :)

  20. Michael Scott says:

    Thanks for republishing this. I am slowly teaching myself how to navigate the WP platform and articles such as this help me to do so.

  21. puanthanh says:

    Using plugin or code to clean other things is not the ideal way. Just remove it. Functions are all actions. SO it will definitely slow down loading time or even eat more resources. Well I agree with the sprite technique.

  22. Brett Widmann says:

    Unnecessary plugins will slow down load time so its a good idea to only use essential ones that will best satisfy your audience and yourself.

  23. David says:

    As apposed to conditional statements for the plugin javascript, what about a conditional statment for the entire plugin?

    Part way down:

    It doesn’t look like the most elegant method, but if it works, it works.

    • Editorial Staff says:

      When you modify the plugin file, then you cannot upgrade it without losing those modifications. That is why it is better to use conditional tags in your functions.php file.

  24. Andrei says:

    Thanks for the post, it’s really useful!

  25. Danny van Kooten says:

    Good post, combining the styles and scripts is a good start but IMO all plugin authors should use conditional plugin loading too. (example: only loading plugin’s backend when actually IN the backend.)

    • Editorial Staff says:

      Good point Danny. I guess its hard to educate every plugin author in the open source platform (because we have so many of them).

      • David says:

        This post is a blatant copy of Justin Tadlock’s article “How to disable scripts and styles” and I don’t see you giving any credit to him. You only mention him in additional resources which is hardly recognizing him as the source. Did you get permission?

        Naughty Naughty.

  26. vickie says:

    Many thanks for this – I’ve been having major performance problems and (apart from database hosting issues) have resorted to removing almost all plugins. Not great, but it’s better than having a site that doesn’t load!

    Will definitely try and work through the changes but is there anything that can be done without going near code for real novices?

    • Editorial Staff says:

      To do something like this, you would need to touch the codes. For real novices, we recommend you hire a professional developer who can do this for you. We are available for hire :)

      • vickie says:

        Current host is ok/helpful but they don’t seem to know much about wordpress. I’ll try changing to one of your suggested hosts first …I’ll be in touch after if I still have problems. Thank you :)

  27. Rolograaf says:

    What happens if there are updates for the plugins? Will you have to do this all over again?

    • Editorial Staff says:

      Not for the most part. Some plugin authors do tend to register other styles if they update, but majority of upgrades deal with programming end rather than front end. So it would depend on the nature of the update.

  28. Danielriggs says:

    Someone should make a plugin to do this!

  29. Daniel15 says:

    Note that if you add styles to the style.css file, they will be overwritten if/when you update the theme. Some themes have a custom CSS file (called something like “custom.css”) you can add your own rules to.

  30. Junthit lee says:

    I did just a few plugins on my blog. I think this tips working like a charm..thanks admin.

  31. Bradley says:

    Nice post. I use Contact Form 7 and had been looking for a way to only allow the javascript to load on the contact page.

  32. Noor Mustafa says:

    This is very helpful piece of information for WordPress optimization

  33. Gursimran says:

    Awesome post!!! I am trying this… ‘ll let you know the results.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.