Revision: 14474
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 5, 2009 00:11 by jdbartlett
Initial Code
/** * Google Ajax Libraries API handler for CakePHP * * Neat trick to load local versions of JavaScript libraries while * debugging, but Google-hosted versions for production. * Automatically detects whether debugging is turned on, and * defaults to jQuery, the best JavaScript library. * * Just shove it in your <head> and forget about it :) * I usually store it somewhere like: /elements/google-jsapi.ctp */ if (!isset($library)) $library = 'jquery'; if (!isset($useLocal)) $useLocal = (Configure::read('debug') != 0); if (!$useLocal) e($javascript->link('http://www.google.com/jsapi')); else $library .= '-local'; switch ($library) { case 'jquery': e($javascript->link('google-jsapi-jquery')); break; case 'jquery-local': e($javascript->link('jquery')); e($javascript->link('jquery-ui')); break; case 'prototype': e($javascript->link('google-jsapi-prototype')); break; case 'prototype-local': e($javascript->link('prototype')); e($javascript->link('scriptaculous')); break; }
Initial URL
Initial Description
[Google's "AJAX Libraries API"](http://code.google.com/apis/ajaxlibs/) is great and all, but can slow things down if you're doing a lot of refreshing/cache clearing while debugging. Here's a neat trick: stuff something like this in the `<head>` of your CakePHP Layout to use local versions of these libraries while you're debugging:
Initial Title
Google Ajax Libraries API handler for CakePHP
Initial Tags
cakephp
Initial Language
PHP