[TYPO3-project-4-3] JS-Files in BE

Martin Kutschker masi-no at spam-typo3.org
Tue May 19 09:52:57 CEST 2009


Steffen Kamper schrieb:
> Hi,
> 
> while adding JS-files in BE-modules the method isn't sufficient.
> 
> There is the $this->doc->JScodeLibArray where files are added to the
> head. But mostly you need something like
> 
> - js files
> - js inline code
> - js files that depends on the inline code
> 
> Best example is recycler which needs to have the inline vars for the
> objects. For this reason the files are added to the inline code manually
> which is bad mannar, as JScodeLibArray is used for being unique avoiding
> double includes.
> 
> So i suggest having optional parameter:
> 
> function loadJavascriptLib($lib, $position = 'top')    {
>     if (!isset($this->JScodeLibArray[$lib]))    {
>         $this->JScodeLibArray[$lib] = array(
>              'position' => $position, // top or bottom
>              'tag' => '<script type="text/javascript" src="' .
> $this->backPath . $lib . '"></script>'
>         );
>     }
> }
> 
> render will be done
> * JSlibs top
> * inline JS
> * JSlibs bottom
> 
> In the next step this could be concatenated and minified and cached.
> 
> What do you think?

That 'top' is ambiguous. Is there a use-case where you want to make sure
a JS library is loaded as the first one *after* the inline JS code?

Masi


More information about the TYPO3-project-4-3 mailing list