Re: [whatwg] Preloading and deferred loading of scripts and other resources

Ian Hickson writes:

> Here's how [the proposal] would handle the use cases listed above.
> 
> > [Use-case G:] A website knows there's a piece of Javascript code
> > that the user might need if they click on a part of the page. The
> > developer would like to have the user download it, but not at the
> > expense of other resources.
> 
>    <script src="button-reaction.js" id="reaction"
>            load-policy="when-needed precache low-priority">
>     // button-reaction.js defines react()
>    </script>
>    <button type=button 
>            onclick="document.scripts.reaction.load().then(
>                     function() { react(); })"> Part of the Page </button>

What does low-priority add in case G? How does that differ from case H,
where "when-needed precache" is sufficient to avoid delaying other
things from loading?

> > [Use-case H:] A website is prefetching photos in a photo album and
> > would like to make sure these images are lower priority than images
> > the user is actually viewing.
> 
>    <img src="photo1.jpg" alt="..." load-policy="when-needed precache">
>    <img src="photo2.jpg" alt="..." load-policy="when-needed precache">
>    <img src="photo3.jpg" alt="..." load-policy="when-needed precache">
>    <img src="photo4.jpg" alt="..." load-policy="when-needed precache">
>    <img src="photo5.jpg" alt="..." load-policy="when-needed precache">
> 
> As they come into view, they'll become needed automatically. When they
> are not needed, they get precached if that wouldn't get in the way of
> other things getting loaded.

Thanks.

Smylers
-- 
http://twitter.com/Smylers2

Received on Tuesday, 26 August 2014 13:58:58 UTC