[TYPO3-core] RFC: Load javascript libraries

Oliver Hader oh at inpublica.de
Wed Sep 19 17:39:23 CEST 2007


Hi Benni,

Benjamin Mack schrieb:
> Hey Thomas,
> 
> Thomas Hempel wrote:
>> What about a more general approach?
>> If we use the complete path as $lib parameter we don't have hardcoded
>> paths and the lib scripts can have diferent names than the library
>> itself. Mootools is an example, where the file is called
>> mootools.v1xxx.js.
> Yeah, but I think we need to rename it to "contrib/mootools/mootools.js"
> in our contrib directory, because what happens if we decide to ship
> mootols.v1.0.1 and in 4.3 we'd go with mootools.v1.1.1 we'd need to
> still keep both versions because extension might have this (hardcoded)
> in their files

Having a function that holds information about which JavaScript library
was integrated is absolutely required. But I wouldn't put this to
template.php but more to t3lib_div. The libs could also be used for
front-end disposal - so putting this to template.php has no effect in
that case.

Another thing is, that there are some extensions in the TER which have
some JavaScript library inside (e.g. extension "scriptaculous"). So, it
might be possible that different scripts do the following:

loadJavaScriptLib('contrib/prototype/prototype.js');
loadJavaScriptLib('contrib/scriptaculous/scriptaculous.js');
loadJavaScriptLib('typo3conf/scriptaculous/lib/prototype.js');
loadJavaScriptLib('typo3conf/scriptaculous/src/scriptaculous.js');

With an approach storing the filepath, all files would be integrated
together. A better one would be to extract and store only the filename,
e.g. 'prototype.js', of the library to be loaded.

> loadJavascriptLib("contrib/mootools/mootools.v1.0.1.js");
> 
> and then we'd have endless legacy trouble shipping tons of different
> versions.
> 
> I could agree with a
> 
> loadJavascriptLib("contrib/mootools/mootools.js");
> 
> then the extensions would automatically get the latest versions.

I don't think that it's required for the Core to have different versions
of a library. I hope, that most parts of new versions of a library are
backwards-compatible (oooh, here's that cow again ;-) ). It might
happen, that libraries depend on others, but there's nothing we can do
against, if those are installed as extensions. For the Core, we have to
take care about that - this is one reason the prototype/script.aculo.us
libraries haven't been updated yet - script.aculo.us is still beta and
the current stable release (1.7.0) won't work with the new prototype
(1.5.1).


olly
-- 
Oliver Hader
http://inpublica.de/


More information about the TYPO3-team-core mailing list