Note that there are some explanatory texts on larger screens.

plurals
  1. POServing CSS and JS in single files, possible advantanges and drawbacks
    primarykey
    data
    text
    <p>I noticed some time ago that many big sites sometimes serve their CSS and JS files in a surprisingly small number (even one single file) and with strange alphanumeric names. What I thought was that these filenames were hashes, which in turn lead me to suspect that:</p> <ul> <li>They were cached</li> <li>They were dynamically created to reduce the amount of HTTP overheads from various CSS and JS "bits"</li> </ul> <p>Some internet research showed me that I was right and this approach is somewhat existent and valued, and I would like to implement it in a WAMP/LAMP site I'm developing - a site that, for its modular plugin structure, serves often a lot of tiny and medium-sized CSS and JS files. <hr> These are my questions:</p> <ol> <li>how can I update the cache automatically on file update? The solution I came up with was to create a sort of "signature string" for every page, joining the file paths AND the last modification time, then hash the signature with MD5 and feed it to the cache to determine if the hash/filename is existent. Is it a correct approach? any drawbacks?</li> <li>the next logical step would be <strong>minification</strong>. Minifying CSS files is rather simple; is JS minification reliable too? Any good class out on the internet?</li> <li>another problem: what about already minified scripts? The only solution aside some form of parsing I thought of was to compare size before and after minification, if size after &lt; size before then use the PHP-minified form. Computational overhead should be solved by caching, right?</li> <li><strong>The most important issue</strong>: <strong>CSS images</strong>. Here I <em>really</em> don't have a clue: collecting various CSS in different places <em>breaks all the relative image links</em>. I cannot use absolute paths (break site relocability). I'd prefer not using a standard directory structure for CSS images (f.ex. placing all CSS referenced images under a <code>css/img</code> dir) because of potential filename conflicts. This would mean also parsing the CSS in some way. How can I solve this?</li> <li>Compression: do I have to implement always a software PHP based GZIP compression, or (very ignorant in that field) can it be enforced automatically on an Apache server?</li> </ol> <p>Thank you for your attention.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload