[dev] potential optimizations: static css and javascript

Chuck Hagenbuch chuck at horde.org
Sat Oct 16 21:58:27 PDT 2004


Quoting Jan Schneider <jan at horde.org>:

>> While I was at it, it seemed prudent to add a js/ directory as well for .js
>> files that really are static and don't need *any* PHP; no reason to involve
>> javascript.php in those.
>
> This is already possible, but the .js files can sit in any directory, like
> htmlarea.js in services/editor/htmlarea/ for example. But of course these
> files need to be in an accessable directory, i.e. not in templates.
>
> What I actually want to say is, yes, why not.

:)

>> The files that really do need PHP can stay in
>> templates/javascript but be renamed to .php, and Horde::addScriptFile() can
>> check the file extension to figure out where to find it.
>
> Lost you here.

If we take the javascript files that contain some php code, and leave them in
templates/javascript, but change them to be file.php instead of file.js, then
we can use Horde::addScriptFile() to add both static (/js/foo.js) and dynamic
(javascript.php / templates/javascript/foo.js) by having Horde::addScriptFile
check the extension (.php or .js) of the file that's passed in, and thus have
it do the right thing (use javascript.php, or use a direct url).

-chuck

-- 
"But she goes not abroad in search of monsters to destroy." - John 
Quincy Adams


More information about the dev mailing list