W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] Link.onload

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Sat, 14 Mar 2009 14:46:37 -0700
Message-ID: <c9e12660903141446w57e5c001w3adfabb529fb3c84@mail.gmail.com>
On Sat, Mar 14, 2009 at 1:48 PM, Greg Houston <gregory.houston at gmail.com> wrote:
> This is a request for the link element to be given an onload attribute.
>

I see.

> Often when lazy loading a plugin into an web app it is necessary for
> the plugin's stylesheets to be applied before the plugin's JavaScript
> is downloaded. Without the link element having an onload event there
> is not really a straightforward way of doing this.
>

It sounds like you want to load resource with dependencies.

> Currently I am using XMLHttpRequests to grab the stylesheets first
> since XHR has a success callback, and then appending the stylesheets
> to the document.head relying on the browser using the cached
> stylesheet. This seems to work for the most part, but really there are
> no guarantees.

When a stylesheet is added to the document, how (or even if) the
resource is downloaded and applied is not part of any official
standard.

>
> There are other odd workarounds but none of them as straightforward,
> elegant, and easy to use as the link elements simply having an onload
> attribute.
>

I proposed a solution to a similar problem not too long ago.

<script depends="[idref]" ...></script>

This would allow for scripts to run without having to wait for
stylesheets to load. When the browser parses <script depends="...", it
looks for elements matching ids in the depends attribute and downloads
all of them before running the script.

This could be used for other resources, too.

<object depends="[idref]">
...
</object>

- where [idref] is the stylesheet to be loaded.

> Thank you for your consideration.
>

You seem optimistic.

Check the thread: "[whatwg] defer on style, depends"

http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-February/018420.html

The first sentence:-
| This is a request for the link element to be given an onload attribute.

Example:-
<link onload="loadPlayer()" ...>

- would solve your problem, but with less simplicity than the
depends="[...]" would.

> Greg Houston
>

Garrett
Received on Saturday, 14 March 2009 14:46:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:47:49 GMT