Changing dependencies during the load process.

Ian Hickson ian at hixie.ch
Wed Aug 20 16:37:43 PDT 2014


On Wed, 20 Aug 2014, John Barton wrote:
> On Wed, Aug 20, 2014 at 3:23 PM, Ian Hickson <ian at hixie.ch> wrote:
> > On Wed, 20 Aug 2014, John Barton wrote:
> > > > >
> > > > > The reverse case, where a img depends on a script, is not a use 
> > > > > case.
> > > >
> > > > Why not? What if the image has an onmouseover handler that calls 
> > > > an API function defined in a module, for instance?
> > >
> > > Then the page depends on the onmouseover handler code and it has a 
> > > dependency on the module. Images are leaf nodes in the dependency 
> > > tree.
> >
> > Can you show me the markup for how you would like this to work? I'm 
> > not sure I follow what your vision is here.
> 
> <script>
> System.import('jquery').then(() => {
>   $(document).ready(() => {
>     $("img.a").hover(() => {
>       $(this).stop().animate({"opacity": "0"}, "slow");
>     }, () => {
>       $(this).stop().animate({"opacity": "1"}, "slow");
>     });
>   });
> });
> </script>
> 
> Here the page depends upon a mouseover handler which depends upon 
> jquery. The handler and the page depend upon the image.

This doesn't do what I was describing. I apologise for being unclear.

The idea is that the jQuery module in this world doesn't get loaded until 
it is needed. When the user hovers over the image, then the jQuery module 
is loaded and used, but until then, nothing needs jQuery so it's not 
loaded. (Or replace jQuery with whatever it is that's special to this 
image; the precise library doesn't matter.)


> > > If you don't want multiple round trips, import from a "bundle".
> >
> > That doesn't work; see the discussion in this e-mail:
> >    https://mail.mozilla.org/pipermail/es-discuss/2014-August/038853.html
> 
> So I answered on another thread.

Ah, looks like your e-mail got caught by my spam filters. I'll continue to 
respond there.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the es-discuss mailing list