Am 12.09.2012 15:47, schrieb Donald Gilbert:
> In a perfect world, that would be ideal.
>
> However, how many extension developers do you know that build sliders that
> are js agnostic, leaving the choice of js framework up to the end user? I
> don't know of any.
Unfortunately, I don't neither. Nevertheless, everything we do should
get us nearer to the ideal, shouldn't it?
> And I don't think that this is how end users want it.
> They want to be able to buy an extension, plug it in, and have it all work.
> That frame of mind (which IS the majority of what I see) kills this
> implementation.
Not necessarily. The extension developer would provide the information,
that the extension supports sliders and tabs, eg.
supports: {
slider,
tabs
}
or, in a less ideal case, that the extension requires it
requires: {
slider,
tabs
}
The (Joomla!-) installer gives this information to the site builder, so
the site builder can decide, if he wants to install a slider plugin (in
case of 'supports') and which. Look at the PEAR installer or Composer
for an example for such a mechanism.
> Also, dependency information is not contained in the template in my
> proposal. You can do a final override within the template head if you
> desire, but it is not required. The extension developers would register all
> their scripts and dependencies using registerScript,
Ok so far. Some questions:
1. What happens, if one extension developer thinks, that "XYSlider"
(depending on jQuery 1.2) is so cool, another developer requires
"ABCSlider" (depending on jQuery 1.8), and a third wants "MooSlider"
(depending on MooTools 1.4)?
Currently, all three frameworks will be loaded, leading to three
different solutions for the same problem, and having negative impact on
the user experience (loading time and broken corporate identity).
With my approach, the extension developer simply does not have that
choice. He can just request a slider.
How would that be solved with your approach?
2. What happens, if a site builder wants to use "SuperSlider" instead of
the "UberSlider" he used until now?
Currently, the site builder does not have that choice.
With my approach, the sitebuilder just changes the slider entry in the
config file.
How would that be solved with your approach?
> You are right on the point that our solutions in reality only differ on the
> point of where is dependency declared. You say in a config file, that at
> some point get's imported by the builder, and then processed (I'm assuming
> by PHP) to enqueue all the required scripts to the document head. I suggest
> declaring the script dependency in PHP, bypassing the config file. Would
> you say that's a fair assessment?
Yes, that is it, but not all (see question above).
> If so, what builder exists to import these config files and do that heavy
> lifting?
Don't know - haven't searched for a thing like that until now. But there
are solutions for dependency resolution out in the wild (PEAR, Composer,
MooTools' packager), so that is feasible.
> I think the closest thing Joomla has to that is JDocument. But
> JDocument doesn't currently have the ability to sequence required scripts
> except - they are included in the order that addScript is called while a
> page is being rendered.
We agree on this being far from ideal. That's why we discuss alternaive
solutions.
> I dare say that a registerScript method could be a
> stepping stone to this more ideal implementation wherein the config file
> holding the dependencies will be imported and then processed by the builder
> using the registerScript method. Then developers (eventually) have the
> choice to either directly declare their dependencies, or declare them in a
> config file.
So this would be the workflow?
- JDocument (better: an HTML render class, but that's another story)
loads the config file(s).
- Extensions may call registerScript() to provide additional
information (the question about precedence has to be answered yet).
- Extensions declare their need using behavior().
- JDocument (renderer) resolves the dependencies and loads the needed
scripts. It of course uses caching and optionally precompiles the
script combination into a single (minified) file.
> Also, I don't like the term "behavior" for what we are doing. Maybe
> JDocument could have an enqueueScript function that takes a string name and
> includes the named script with any dependencies.
I think "behavior" is a very precise term for what we want here. We want
a piece of the markup to behave as a slider. To use scripts for that is
one possible solution, but some day it may be solved with CSS (see
DropDown menus for example).