[TYPO3-project-4-3] JS-Files in BE
Steffen Kamper
info at sk-typo3.de
Tue May 19 01:45:53 CEST 2009
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?
vg Steffen
More information about the TYPO3-project-4-3
mailing list