MyBB Community Forums

Full Version: How to Minimize Stylesheets Queries
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

How I can I make a static css file which don't need to be called via a php file everytime i m on a new page on my forum.

I have about 30,000 visitors everyday on my site, and I see that the queries which taking most of the server resources are the php files calling the stylesheets.

Please help Smile

Thankyou
Combine all the CSS files into one (minify it if you wish) and upload that file wherever you want (./css/style.css for example).

Then go to Admin CP > Templates & Style > Templates > Your Template Set > Ungrouped Templates > headerinclude.

Find:

{$stylesheets}

Replace with:

<link type="text/css" rel="stylesheet" href="css/style.css" />
Can I Upload this css file on another server and how many stylesheets there are total, so when i join them i don't miss any.

And Can i do it for showthread only.

Thankyou
Yes, you can upload it elsewhere. Just replace the href with the direct link to the CSS file.

There are five stylesheets total by default: global.css, usercp.css, modcp.css, star_rating.css, showthread.css. Only the first one is used throughout the entire forum though, the rest are used in specific pages. So you'll be loading some styles when they are not necessary.

However they are minimal in size compared to global.css, so it's probably not a big deal to combine them all together. In the end it's quite worth it if you also minify and compress the file. You'll have less HTTP requests, less queries and smaller files.
Thanks its working Smile

How to minify css - it is about 17 Kb now.
Just use a site like CSS Minify. Paste in the CSS code and it will give you back the minified version, which you should then use in your file.

Make sure to keep a backup of the full version though, as you might need to edit the CSS at some point, and minified CSS is pretty hard to read.
(2012-05-07, 12:50 PM)Fábio Maia Wrote: [ -> ]Just use a site like CSS Minify. Paste in the CSS code and it will give you back the minified version, which you should then use in your file.

Make sure to keep a backup of the full version though, as you might need to edit the CSS at some point, and minified CSS is pretty hard to read.

what compression is better?
high, highest or standard to avoid problems?