[TYPO3-dev] Best practice for including JS / CSS from an extension

Jigal van Hemert jigal at xs4all.nl
Tue Jun 14 15:15:28 CEST 2011


Hi,

On 14-6-2011 13:24, Peter Niederlag wrote:
> Am 14.06.2011 12:35, schrieb Jigal van Hemert:
>> Hi,
> [...]
>> Maybe you can use the approach I always use for pi_base extensions
>> (thanks to Dmitry for this):
>
> while this is very nice and backwards compat to old TYPO3 versions
> starting from TYPO3 version 4.3 there is an improved API inside
> t3lib_pageRenderer.
[...]
>
> Pro: you don't have to take care of the proper markup and just provide
> the file-name.

Cons:
- it's easy to put them in an HTML template
- CSS/JS can vary per template (which you can often set in the plugin 
flexform; so select other template and you have appropriate CSS/JS). 
This is also accessible for non-admins
- it's (as you said) not compatible with all currently supported TYPO3 
versions

If you want to use the newer API I'd set up two sections in the 
extension's Typoscript where you can define which CSS and which JS 
should be included on a page where the extension is used.
In your extension you can parse those TS sections and call the add*() 
functions for each CSS/JS file.

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert.




More information about the TYPO3-dev mailing list