Feature Proposal: JS/CSS register mechanism
Motivation
Double inclusion of common JS like Prototype should be avoided. JS load order should be customizable.
Description and Documentation
At the moment Javascripts get loaded in two ways:
- via a TWiki::Func::addToHeadI() call
- via manipulating the html output (head block) in a commonTagsHandler or PostRenderingHandler
With 1.) you have no influence on the order. In most cases the JS gets appended to the head block. Method 2.) looks somehow ugly.
In every case you manually have to take care if the JS is already included. This is important for common JS like Prototype. The other way around from the plugins authors perspective you have to chance to figure out, if a certain JS was already included (which your JS / plugin depends on).
See also:
Bugs:Item1889
Examples
Impact and Available Solutions
Implementation
--
Contributors: OliverKrueger
Discussion
--
OliverKrueger - 31 Aug 2006
How bad is double inclusion? If file are read from the cache the load would be minimal.
--
ArthurClemens - 31 Aug 2006
If the JS is only referenced, the impact is quite minimal. Double-inclusion is probably only a problem, if you put the actual code in there.
But double inclusion is only one aspect of this topic. The more important one (for me) is the load order.
--
OliverKrueger - 31 Aug 2006
At what level would be decided what the 'correct' order is? In the templates?
--
ArthurClemens - 31 Aug 2006