Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For javascript, I use <a href="http://dean.edwards.name/download/#packer" rel="nofollow noreferrer">Dean Edwards's Javascript Packer</a>. It's been ported to .NET, perl, php4, php5, WSH, and there's even an aptana plugin.</p> <p>Javascript packing comes in a few flavours - some just strip out comments and whitespace, others will change your variable names to be concise, and others, well, I don't even know what they do, but the output sure is small. The high-end compression works by using the eval() function, which puts some extra burden on the client, so if your scripts are particularly complicated, or you're designing for slower hardware, keep that in mind. the Javascript packer gives you the option for which compression level you want to use.</p> <p>For CSS, the best you can do is strip whitespace and comments. Thankfully that means that you can achieve that with a one-line function:</p> <pre><code>function compressCSS($css) { return preg_replace( array('@\s\s+@','@(\w+:)\s*([\w\s,#]+;?)@'), array(' ','$1$2'), str_replace( array("\r","\n","\t",' {','} ',';}'), array('','','','{','}','}'), preg_replace('@/\*[^*]*\*+([^/][^*]*\*+)*/@', '', $css) ) ) ; } </code></pre> <p>While that function and the Javascript packer will reduce the file size of individual files, to get the best performance from your site, you'll also want to be reducing the number of HTTP requests you make. Each Javascript and CSS file is a separate request, so combining them into one file each will the the optimal result. Instead of trying to maintain a single bohemoth JS file, you can use the program/technique I've written on my blog (shameless self plug) at <a href="http://spadgos.com/?p=32" rel="nofollow noreferrer">http://spadgos.com/?p=32</a></p> <p>The program basically reads a "build script"-type file which will simultaneously combine and compress multiple Javascript and CSS files into one (of each) for you (or more, if you want). There are several options for the output and display of all files. There's a larger write-up there, and the source is freely available.</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.
    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