How to combine CSS files into one using PHP
Hi,
You can use CSS combining software to allocate many CSS files within one file.
There are some steps to do this.
Gzip will compress the PHP file.
Online lessons are also beneficial to make it understand clearly.
I can present here an address which exhibits all the necessary steps for completing this task.
Thanks.
How to combine CSS files into one using PHP
Hi Mr,
You can use this site for a good quality. I hope this is a much better system. Just go to this site and you will be able to solve your problem. http://electrokami.com/Â Copy your code and then to be converted.
Another site this is a not better then previous site: https://www.giftofspeed.com/css-compressor/
Thanks
How to combine CSS files into one using PHP
Hello Jibinjohn,
 With performance in mind I set the following criteria for your solution-
It should cache combined files to increase performance.
When a CSS or JavaScript file is modified the cache should be expired.
It should send a 304 when appropriate.
It should perform more requests a second than requesting the multiple files individually.
It should decrease load on the server.
Here’s an example of a link tag for including multiple CSS files into one request-
<link rel="stylesheet" href="/combine.php?test1&test2" type="text/css">
The combine.php script will infer what files to include from $_GET. In this case it will try to combine a test1.css file and a test2.css file. Let’s have a look at the code I’ve written to meet the first 3 criteria and then we’ll find out if there are any performance benefits.
Most of the big websites have many css files and the browser need to load them one by one.
There is a easy solution to merge them to one file using php.
css_loader.php
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php
// First of all send css header header("Content-type: text/css"); // Array of css files // Loop the css Array    // Load the content of the css file    // print the css content |
Â
1
|
<link href="css_loader.php" rel="stylesheet" type="text/css" />
|
Now all the CSS files are merged into one file.
Thanks,