Imho it is not smart to use sub-domain for some that can be done without.
Each file which has to be called makes a http request, so in your scenario 3 http request for actualy just one file...because 3 subdomains are at least 3 calls if each part is on one. I won't say it is not faster but imho not smart.
To hand a simple small code for the answer John Conde already gave, if it is about minify
you could use following file. Give it a name whatever you wish as long it has the .php extension all will be fine.
The big advantage this way, it minify on the fly and will only need a refresh when you have changed some (it will detect itself when needed) and you still can add/edit the original uncrunched files.
I have 5 files which will be "collected" by the code and send 1 as output and it is minified. You maybe even want to serve if from a CDN if still needed.
<?php
/* Add your CSS files to this array */
$cssFiles = array(
"style.css",
"css/01_basic.css",
"css/02_comments.css",
"css/03_sidebar-widgets.css",
"css/04_additonal.css";
/** Ideally, you wouldn't need to change any code beyond this point. */
$buffer = "";
foreach ($cssFiles as $cssFile) {
$buffer .= file_get_contents($cssFile);
}
// Remove comments
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
// Remove space after colons
$buffer = str_replace(': ', ':', $buffer);
// Remove whitespace
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
// Enable GZip encoding.
ob_start("ob_gzhandler");
// Enable caching
header('Cache-Control: public');
// Expire in one day
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT');
// Set the correct MIME type, because Apache won't set it for us
header("Content-type: text/css");
// Write everything out
echo($buffer);
?>
I found the original code here On-the-fly. (it is awesome imho)
To use this in your HTML, link to it in the usual way:
<link rel="stylesheet" type="text/css" media="screen, print,projection" href="path/to/your/compressed.css.php" />
The 86400
is the expire for the file, set another time if wished.
Please don't forget to rename css-folder & css-file names.