Updating Extensions to use script zone instead of VarADDTOHEAD

Example

Current extensions, such as JQueryPlugin, no longer add <script> markup using ADDTOHEAD.

From Foswiki 1.1 onwards and Foswiki 1.0.x using ZonePlugin, the following perl code will no longer guarantee that JQUERYPLUGIN markup will be ordered before id content:
Foswiki::Func::addToHEAD("id", "<script>...</script>", "JQUERYPLUGIN");

The same applies to the following TML equivalent:
%ADDTOHEAD{"id" text="<script>...</script>" requires="JQUERYPLUGIN"}%

The reason is that all <script> markup should be added to a dedicated zone, script, and so any usage of ADDTOHEAD - which adds to the head zone - will be unable to satisfy ordering requirements when the requirements exist in another zone ( script ).

ALERT! Exception: When {MergeHeadAndScriptZones} is enabled in configure, Foswiki will try to satisfy missing ordering requirements by treating the two zones as one merged zone. However, this feature will be removed from a future version of Foswiki. It is only provided to offer some temporary compatibility until reliance on the old ADDTOHEAD conventions can be eliminated.

The two examples above are re-written here using the new script zone:
Foswiki::Func::addToZone("script", "id", "<script>...</script>", "JQUERYPLUGIN");

The same applies to the following TML equivalent:
%ADDTOZONE{"script" id="id" text="<script>...</script>" requires="JQUERYPLUGIN"}%

Refer to the ADDTOZONE documentation for more information.

-- PaulHarvey - 05 Sep 2010
Topic revision: r1 - 05 Sep 2010, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy