Heute war mal wieder Optimierungstag für diverse Drupal-Projekte. Dabei setzte ich das erste mal erfolgreich das Advanced CSS/JS Aggregation Modul ein. Nach ein bißchen Finetuning wandelte sich die von YSlow getestete Seite von einem durchschnittlichen C in ein schönes A.
Allerdings gab es noch immer Verbesserungen die ich umsetzen wollte und dazu gehörte die Installation der pecl-jsmin Library denn schliesslich sagte mir Drupal in der Advagg-Konfiguration unter admin/config/development/performance/advagg/js-compress:
You can use the much faster C version of JSMin by installing the JSMin PHP Extension on this server.
Okay, auf geht´s dachte ich mir und fand etwas weiter unten auf der Downloadseite der pecl-jsmin library eine Standard-Installationsanleitung die ich als Ausgangsbasis für dieses HowTo genutzt habe.
1. pecl install jsmin-beta
downloading jsmin-0.1.1.tgz ...
Starting to download jsmin-0.1.1.tgz (7,861 bytes)
.....done: 7,861 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
shtool at '/tmp/pear/temp/jsmin/build/shtool' does not exist or is not executable.
Make sure that the file exists and is executable and then rerun this script.
If the command failed with 'phpize: not found' then you need to install php5-dev packageYou can do it by running 'apt-get install php5-dev' as a root userERROR: `phpize' failed
Das lag daran das mein tmp Verzeichnis einige Sicherheitseinschränkungen hat und dort z.B. nichts ausgeführt werden kann. Also musste ein Verzeichnis her in dem executed werden darf und Pecl sollte wissen wo sein neues Temp-Verzeichnis ist
2. sudo mkdir /jsmin && sudo chmod 770 /jsmin && sudo chown ich.root /jsmin
3. sudo pear config-set temp_dir /jsmin/
config-set succeeded
Vorher noch ein kurzer Check ob shtool installiert ist:
4.sudo apt-get install shtool
Reading package lists... Done
Building dependency tree
Reading state information... Done
shtool is already the newest version.
shtool set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Alles klar, dann kann jetzt das jsmin Paket installiert werden.
5. sudo pecl install jsmin-beta
downloading jsmin-0.1.1.tgz ...
Starting to download jsmin-0.1.1.tgz (7,861 bytes)
.....done: 7,861 bytes
6 source files, building
running: phpize .....................................
Build process completed successfully
Installing '/usr/lib/php5/20100525/jsmin.so'
Installing '/usr/include/php5/ext/jsmin/php_jsmin.h'
install ok: channel://pecl.php.net/jsmin-0.1.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=jsmin.so" to php.ini
6. sudo vi path/to/php.ini
extension=jsmin.so
eintragen und Apache neu starten. Jetzt kann man unter admin/config/development/performance/advagg/js-compress diesen schönen Eintrag sehen:
JSMin is the C complied version and is about 25 times faster. Recommend using it.