News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Felix Geisendorfer's Blog:
Include only the JS you really need
November 20, 2006 @ 07:46:00

In his latest entry, Felix shares a quick tip for CakePHP users out there to help them reduce the sizes of their pages and speed things up a little bit by including only the Javascript that you really need as a method inside your controller.

The basic idea is the addition of two functions and a variable to set the jsIncludes value and an includeJs/excludeJs pair to do the actual loading. The result is a much cleaner call to includeJs when rendering the application that will automatically pull in the files specified.

So if up to now you've always included all JS for every page load, this might help to reduce bandwidth usage for both you, and the users of your application. I know this is not the most advanced solution one could come up with. [...] But then I decided that it's too simple a problem for that kind of bloat.

All of the code is included here.

0 comments voice your opinion now!
cakephp javascript include define function variable controller cakephp javascript include define function variable controller


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Using JavaScript in PHP with PECL and SpiderMonkey

Developer Tutorials Blog: Debugging CakePHP applications in Zend Studio for Eclipse

Lorenzo Alberton's Blog: PEAR::Pager - Navigation with Pager and AJAX (or simple Javascript)

Till Klampaeckel's Blog: Zend Framework: Writing an IN-Clause with Zend_Db

Soledad Pendaes' Blog: PHP will never have a (real) Rails-like framework


Community Events





Don't see your event here?
Let us know!


podcast api refactor language interview code introduction framework threedevsandamaybe community symfony2 install testing unittest series developer opinion laravel list release

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework