Kobe, Japan 2010-04-28Osaka, Japan 2010-04-29Nanbudo_Norge2007-12_211Shiga, Japan 2010-04-18Inujima, Japan 2010-04-30Slovenia2009-04_658Nanbudo_Norge2007-12_038playa06secret_552Zoo2006-10-07_043norge5oslo_169Kuortti.2010-06-26South.Africa.Roadtrip.2007-08_353Saaristoleiri-Uto-2008_180Saaristoleiri-Uto-2008_177South.Africa.Roadtrip.2007-08_216Nanbudo_WCh2006_076Kuortti.2010-06-26Somero2002_02Jodo-Milano.2008-09_035Saaristoleiri 2009-08 34Helsinki2005-10-15_16_042Pakkas03Pitkanen_076
Snapshot of a jQuery book

One day in the train with a jQuery book.

Optimising the size of your Javascript

Few simple rules:

  • Combine selected libraries and their plugins in to a one file
  • Minify that file
  • Compress the minified file with Gzip
  • Check with your web site session initialisation if the visitors browser supports Gzip
  • Offer either of the files depending of the visitors capabilities.

The server side checking of browsers support for Gzip could be done with the following PHP code:

$_SESSION['gzip'] = false;
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
    if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
        $_SESSION['gzip'] = true;
    }
}

Similarly you could compress CSS files too. For this you could try the YUI compressor.

Time: 18/11/2007 18:19

QR code for paazio.nanbudo.fi