Title: Optimizing WP, combining plugin javascripts and css?
Last modified: August 19, 2016

---

# Optimizing WP, combining plugin javascripts and css?

 *  [tta](https://wordpress.org/support/users/tykho/)
 * (@tykho)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/optimizing-wp-combining-plugin-javascripts-and-css/)
 * Hello,
 * Recently launched a site on a dedicated server, unfortunately I’ve got a big 
   bunch of http requests that slows the site down as soon as there’s traffic. I’ve
   got a grade D on Yslow.
    I know of minifying css and javascript, and also of 
   combining in order to get less http requests.
 * Problem is, most of them are from various plugins used on the site. Slideshow
   gallery, events-calendar, wp e-commerce, mtouch-quiz, contactform etc etc etc…
   and many of them are located in the head of the document, and will break plugins
   used on the site if moved around.
 * Is it somehow possible to combine plugin javascripts? Will I have to manually
   edit the plugins and point them to a manually combined javascript every time 
   they call on some JS? Same goes for all the css files the plugins are requesting.
   
   Anyone had a similar problem and found a solution?

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

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/optimizing-wp-combining-plugin-javascripts-and-css/#post-1892418)
 * you can remove css and properly registered javascript from your header this way.
   Put this in your theme’s functions.php.
 *     ```
       add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
       function my_deregister_styles() {
       	wp_deregister_style( 'wp-pagenavi' );
              // deregister as many stylesheets as you need...
       }
   
       add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
       function my_deregister_javascript() {
              wp_deregister_script( 'contact-form-7' );
              // deregister as many javascript files as you need...
       }
       ```
   
 *  [cockpitseeker](https://wordpress.org/support/users/cockpitseeker/)
 * (@cockpitseeker)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/optimizing-wp-combining-plugin-javascripts-and-css/#post-1892891)
 * [@tykho](https://wordpress.org/support/users/tykho/):
    you can try combining 
   files for your issue. [W3-total-cache](http://wordpress.org/extend/plugins/w3-total-cache/)
   allows you to do it for both CSS and JS, which even gives you the option to modify
   the files order for the output combined file and the ability to exclude some 
   files if you still have dependency issues.
 * I do see a problem though.
    With my particular setup, this combining plugin breaks
   and I figured I would manually combine, with the [combine.php script of Rakaz](http://rakaz.nl/code/combine).
 * Following the instructions, when setting up the script, I see **1 problem:**
    - wordpress structure does not have only 1 folder for CSS
    - same for JS
 * given that every theme and plugin has its own set of files, within their own 
   path.
 * Thus when looking at:
    `$cssdir = dirname(__FILE__) . '/css';` to specify a CSS
   folder, **I wonder if it would be syntaxly correct** to change it to, for instance:`
   $cssdir = dirname(__FILE__) . '/wp-content/themes/theme1/css,/wp-content/plugins/
   plugin1/css,wp-content/plugins/plugin2/css';` _(to specify various folders)_
 * Same would go with the JS folder structure.
 * **Is such a syntax valid in php?**

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

The topic ‘Optimizing WP, combining plugin javascripts and css?’ is closed to new
replies.

## Tags

 * [combine](https://wordpress.org/support/topic-tag/combine/)
 * [css](https://wordpress.org/support/topic-tag/css/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [optimise](https://wordpress.org/support/topic-tag/optimise/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [cockpitseeker](https://wordpress.org/support/users/cockpitseeker/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/optimizing-wp-combining-plugin-javascripts-and-css/#post-1892891)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
