Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there any proper wordpress way of including the JS and CSS through one merged URL?

So that instead of loading in x number of separate calls for each JS asset, it can be all merged into one URL? Samething for CSS.

I know this is easy enough to do using straight up PHP, but I wanted to check if wordpress has some nifty way of combining requests.

share|improve this question

3 Answers 3

Wordpress core has not such a mechanism. I've seen Caching plugins who do this. One of them is Semiologic Cache (Wordpress Pluin) and there are probably others who do this as well.

share|improve this answer

The reason this is not automated is because it would wreak havoc on sites. Many plugins, themes, etc have multiple CSS/JS files that conflict when merged.

With a plugin like the one mentioned above you basically have to add the files manually one by one, and see if it breaks anything.

The alternative, which is a way better method but time consuming, is to look into the syntax yourself and combine them manually to avoid conflicts.

share|improve this answer

It is interesting that while WP is capable of and does use script concatenation in admin area - it is not exposed or suggested to be used in site itself.

I suppose with some tinkering it might be possible to make use of core, but it is way easier to make use of existing plugins.

I use W3 Total Cache, it has extensive CSS/script concatenation support.

share|improve this answer
    
thanks... that looks like a good caching plugin. I'm trying to go no plugin route because I want it to be a one-click theme install. –  AndreLiem Dec 5 '10 at 6:55
    
@AndreLiem - for one-click, place the plugin in a subdirectory of your theme and load it manually. plugins are just php includes. –  hakre Dec 5 '10 at 13:40
    
thanks hakre, I actually meant that by installing a theme it comes pre-ready with caching. I'm working on distributing a theme with a bunch of features built in. –  AndreLiem Dec 17 '10 at 23:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.