title: Storing all JS/CSS in PHP?
body: <p><strong>Background:</strong> I'm working on a single page web app that loads everything through AJAX and so started learning php a few days ago. I immediately thought of putting everything (html, css, javascript) in php files so that there is only one html file and one sprite request. For instance, external javascript could be stored in:</p>
  
  <p><strong>main.js.php</strong> (adding the .js for organizational purposes only) which would look like:</p>
  
  <pre><code>&lt;script&gt;
   ...
  &lt;/script&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;style&gt;
   ...
  &lt;/style&gt;
  </code></pre>
  
  <p><strong>Question:</strong> Would storing everything in php be a bad idea? I have OCD and like to have related functions in separate files (and actually, folders too), so let's just say my project uses 100+ includes. These only get loaded exactly once, when the user visits (AJAX site). I want to reduce the number of Http Requests to just 1 html and 1 sprite (my app uses a custom font for images actually). My app will also be ran on mobile devices (using a different design, using far fewer includes but a similar method).</p>
  
  <p><strong>Research:</strong> Here's what I know:</p>
  
  <ul>
  <li>You can have Apache handle js/css as php, but is not something I'm interested in (dangerous) - <a href="https://stackoverflow.com/questions/984148">link</a></li>
  <li>This site gave me the idea, although I don't quite understand it - <a href="http://www.catswhocode.com/blog/3-ways-to-compress-css-files-using-php" rel="nofollow noreferrer">3 Ways to Compress CSS</a></li>
  <li>Caching with something like APC (not sure how it works, but out of the scope of this question) would improve php speeds (?)</li>
  </ul>