[From nobody Wed Jul 20 10:37:03 2005 Date: Wed, 20 Jul 2005 16:09:24 +0200 From: "Bart van den Eijnden" <BEN@Syncera-ITSolutions.NL> To: <chameleon@lists.maptools> Subject: compress Chameleon javascript Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_C2E1536D.86E79CA9" --=_C2E1536D.86E79CA9 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi list, I thought this might be of more general interest than just me. Paul Spencer has written a PHP script which can compress javascript by = removing whitespace and comments mainly. I just did this for the Chameleon javascript code, and it got reduced from = 310 Kb in total to 149 Kb. Will save a lot of initial download time for = people accessing your Chameleon site for the first time. This is especially useful for people using the JSAPI mode since that = javascript file is more than 100 Kb. Ofcourse, the best overall option would be gzipping all content by the = webserver, including the HTML file which can turn to more than 100 Kb = itself easily. But I also understand there are quite some issues with GZIP on IIS before = version 6.0, and not everybody might have the option to install mod_gzip = for Apache. Anyway, posting the script also to the list assuming Paul is okay with = that :-) Best regards, Bart Bart van den Eijnden Syncera IT Solutions Postbus 270 2600 AG DELFT tel.nr.: 015-7512436 email: BEN@Syncera-ITSolutions.nl --=_C2E1536D.86E79CA9 Content-Type: application/octet-stream; name="getcjs.php" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="getcjs.php" PD9waHAKLyoKICogY29tcHJlc3MgYSBqYXZhc2NyaXB0IGZpbGUgYnkgcmVtb3Zpbmcgd2hpdGVz cGFjZSBhbmQgb3B0aW9uYWxseQogKiBtb2RpZnlpbmcgdmFyaWFibGUgYW5kIGZ1bmN0aW9uIG5h bWVzCiAqLwpkZWZpbmUoICJKU0RJUiIsICIiICk7CmNsZWFyc3RhdGNhY2hlKCk7CmlmICghaXNz ZXQoJF9SRVFVRVNUWyduYW1lJ10pKQp7CiAgICBlY2hvICJhbGVydCggJ25hbWUgbm90IHNldCB3 aGVuIHJlcXVlc3RpbmcgY29tcHJlc3NlZCBqYXZhc2NyaXB0IGZpbGUnICk7IjsKIC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ICAgICAgICAgIGlmICgkdHMgIT0gZmlsZW10aW1lKCRmaWxlLiIuanMiKSkK ICAgICAgICAgICAgewogICAgICAgICAgICAgICAgJGJDb21wcmVzcyA9IHRydWU7CiAgICAgICAg ICAgIH0KICAgICAgICB9CiAgICB9CgogICAgaWYgKCRiQ29tcHJlc3MpCiAgICB7CiAgICAgICAg Y29tcHJlc3NKUyggJGZpbGUuIi5qcyIsICAkZmlsZS4iLmNqcyIsICRmaWxlLiIudHMiKTsKICAg IH0KCiAgICAkaCA9IGZvcGVuKCRmaWxlLiIuY2pzIiwgInIiKTsKfQplbHNlCnsKICAgICRoID0g Zm9wZW4oJGZpbGUuIi5qcyIsICJyIiApOwp9CmZwYXNzdGhydSgkaCk7CmZjbG9zZSgkaCk7CmV4 aXQ7CgpmdW5jdGlvbiBjb21wcmVzc0pTKCAkc3pKU2ZpbGUsICRzekNKU2ZpbGUsICRzelRTZmls ZSApCnsKICAgICRzekNvbnRlbnRzID0gZmlsZV9nZXRfY29udGVudHMoJHN6SlNmaWxlKTsKCiAg ICAkYVNlYXJjaCA9IGFycmF5KCcvXC9cLy4qLycsIC8vIGMrKyBzdHlsZSBjb21tZW50cyAtIC8v c29tZXRoaW5nCiAgICAgICAgICAgICAgICAgICAgICcvXC9cKi4qXCpcLy9zVScsIC8vIGMgc3R5 bGUgY29tbWVudHMgLSAvKiBzb21ldGhpbmcgKi8KICAgICAgICAgICAgICAgICAgICAgJy9cc3sy LH0vcycsIC8vMiBvciBtb3JlIHNwYWNlcyBkb3duIHRvIG9uZSBzcGFjZQogICAgICAgICAgICAg ICAgICAgICAnL1xuLycsIC8vbmV3bGluZXMgcmVtb3ZlZAogICAgICAgICAgICAgICAgICAgICAn L1xzPS8nLCAvL3NwYWNlID0KICAgICAgICAgICAgICAgICAgICAgJy89XHMvJywgLy8gPSBzcGFj ZQogICAgICAgICAgICAgICAgICAgICApOwoKICAgICRhUmVwbGFjZSA9IGFycmF5KCAnJywKICAg ICAgICAgICAgICAgICAgICAgICAnJywKICAgICAgICAgICAgICAgICAgICAgICAnICcsCiAgICAg ICAgICAgICAgICAgICAgICAgJycsCiAgICAgICAgICAgICAgICAgICAgICAgJz0nLAogICAgICAg ICAgICAgICAgICAgICAgICc9JywKCiAgICAgICAgICAgICAgICAgICAgICApOwogICAgLy9yZW1v dmUgYysrIGNvbW1lbnRzCiAgICAkc3pDb250ZW50cyA9IHByZWdfcmVwbGFjZSggJGFTZWFyY2gs ICRhUmVwbGFjZSwgJHN6Q29udGVudHMgKTsKCiAgICAkZmggPSBmb3Blbigkc3pDSlNmaWxlLCAi dyIpOwogICAgZndyaXRlKCAkZmgsICRzekNvbnRlbnRzKTsKICAgIGZjbG9zZSgkZmgpOwogICAg JHRzID0gZmlsZW10aW1lKCRzekpTZmlsZSk7CiAgICAkZmggPSBmb3Blbigkc3pUU2ZpbGUsICJ3 Iik7CiAgICBmd3JpdGUoJGZoLCAkdHMpOwogICAgZmNsb3NlKCRmaCk7Cn0KCj8+Cg== --=_C2E1536D.86E79CA9-- ]