Creating faster web pages

7 years 7 months ago #617 by magne
So here's my first tip: use one single stylesheet and javascript file instead of many small ones. I know one big file is harder to maintain, but once your site goes into production, you shouldn't have to change these files often anyway. Some sites like or reference dozens of .css and .js from their front page. Slashdot takes about twenty seconds for me to load from a clear browser cache. Don't go this mad with your css unless you have enough regular readers already. For someone new to your site coming over from Google this will be a major turn off.

If your stylesheets are static files and you would like to keep them seperate for better maintenance, you can bundle them into one request dynamically:

# File css.php
As Kevin Palms points out, you will have to set the header information manually in PHP like this:

# File css.php
header('Content-type: text/css');
# ...
Save this code as a file called something like css.php and reference it from your HTML:

<link rel="stylesheet" type="text/css" href="/css.php" />

Please Logg inn or Create an account to join the conversation.

Moderators: Kai
Time to create page: 0.236 seconds
Powered by Kunena Forum