Zikula Network
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
Subscribe!
Let Google Host Your Ajax Libraries
All Google conspiracy theories aside, Google actively host's popular Ajax frameworks, so why not take advantage of them?
First, if you are wondering what the advantage is, it is rather quite simple. Prototype and Script.aculo.us are very common frameworks. It makes little sense that every time a browser needs one of these popular frameworks that it needs to download it and cache it to your browser. How many copies does your browser needed? Probably just one, as you have guessed. This means every time that a framework is requested from Google, your browser already has it cached, reducing the need for another HTTP request.
But not only is this an advantage to your browser, it also is an advantage to your server, as it less files it has to serve. Less files equates to less server usage and less bandwidth.
We know that Zikula requests these dynamically, and we really do not want to hack the core files to make the redirects, so a simple work around is to have Apache make use of mod_rewrite with an .htaccess file. To keep it simple we will use the .htaccess file at the Zikula root directory.
Since .htaccess files can very with Zikula, you will have to adjust according to your situation. But It should look something like this:
# security optionsphp_flag register_globals off php_flag magic_quotes_gpc off
Options FollowSymLinks RewriteEngine On
# RewriteOptions 'inherit' # Place our new rules about all the other rewrite rules RewriteRule ^javascript/ajax/prototype\.js$ http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js [R=301,NC,L] RewriteRule ^javascript/ajax/script.aculo.us\.js$ http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.1/scriptaculous.js [R=301,NC,L]
This makes a 301 redirect to Google. There you go a quick and dirty guide!
For more information see: http://code.google.com/apis/ajaxlibs/documentation/index.html
Enjoy,
-David Pahl
Share This | Print




