I've been thinking about a way to reduce the number of HTTP requests done whn loading a page by reducing the number of downloaded files, but still keeping separate files of the server.
The idea is to do :
<!DOCTYPE html>
<html>
<head>
<style type="text/css">@import url("../CSS/main.css.php") screen;</style>
<script type="text/javascript" src="../JS/main.js.php"></script>
</head>
<body>
</body>
</html>
And on the server side :
CSS/ foler :
- main.css.php
- main.css
- some_css1.css
- some_css2.css
JS/ folder :
- main.js.php
- main.js
- some_js1.js
- some_js2.js
main.css.php :
<?php
require('main.css');
require('some_css1.css');
require('some_css2.css');
?>
main.js.php :
<?php
require('main.js');
require('some_js1.js');
require('some_js2.js');
?>
Would this way of importing files improve the page download time ? Would it take long for the server to require the files ? Is the gain in download time (if any) greater than the loss of time cause by the extra calculations done by the server ? Any reasons why i should or should not do things that way ?
Thanks in advance :)