[TYPO3-dev] Including jQuery in plugin - Best practice

Michael typo3ml at schams.net
Sun Oct 30 00:51:13 CEST 2011


On 30/10/11 06:25, Jigal van Hemert wrote:

>> Perhaps jquery like t3jquery should be a build in functionality in
>> TYPO3,
[...]
> Including them in the core would mean that the core team has to keep
> track of the updates of all those libraries and possibly ship multiple
> versions...

I am a big fan of jQuery but my feeling is the same as Jigal's. Let the
extensions control to include this (optional) component.

> This is an excellent thing to keep in an extension.

In regards to best practice: if your ext does not depend on a specific
version of jQuery (and it is likely that future versions of jQuery will
work with your ext and should be used), a dependency to t3jquery has the
advantage that you do not need to take care about jQuery updates (but
t3jquery will hopefully do it).

Another approach would be to include jQuery in your ext: you do not
necessarily need to ship the jQuery library in your package but you can
reference to a CDN-hosted copy (explained/discussed in [1] and [2]).

I personally like extensions where site admins can choose to deactivate
the jQuery inclusion in the extensions configuration. The benefit is
that if your site or another ext already uses jQuery, you can easily
avoid multiple inclusions without fiddling about TypoScript to remove them.

Or, if you do the inclusion with TypoScript, do it at least by using
setup.txt and explain in your ext-documentation how to deactivate it if
required.

...just my thoughts :-)

[1] http://docs.jquery.com/Downloading_jQuery
[2]
http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/


Cheers
Michael



More information about the TYPO3-dev mailing list