All [external resource links] have an algorithm to fetch and process the linked resource.
Individual link types may define their own [fetch and process the linked resource] algorithm, which takes the link
element el. But if not otherwise stated, they use the following default fetch and process the linked resource algorithm, given el:
- If el's
href
attribute's value... - ... stuff ...
- Fetch request. To process response given the response response:
- Let success be true.
- If response is a network error, or its status is not an ok status, set success to false.
- Fetch any of the critical subresources of the resource. (TODO: this could be defined better, in particular its affect on success and so on.)
- [Process the linked resource] given el and success.
Similarly, individual link types may define their process the linked resource algorithm, which takes the link
element el a boolean success, and a response response. This typically is done if they want to reuse the fetching steps from the [default fetch and process the linked resource] algorithm, while overriding the processing steps. But if not otherwise stated, they use the following default process the linked resource algorithm, given el and success (ignoring the response):
- Queue a task on the DOM manipulation task source (?) to perform the following steps:
- If success is true, fire an event named
load
at el. - Otherwise, fire an event named
error
at el.
- If success is true, fire an event named
The [process the linked resource] algorithm for stylesheet links is as follows, given el, success, and response:
- If response's content type is wrong, set success to false.
- Fire events according to success.
- If success is true:
- Create/add CSS style sheet
- Decrement the counter
The [fetch and process the linked resource] algorithm for modulepreload links is as follows, given el:
- ... All the steps; never calls process the linked resource, but does its own thing instead ...
The [fetch and process the linked resource] algorithm for preload links is as follows, given el:
- ... Lots of the steps, from whatwg/html#4048, to set up the fetch more specially ...
- [Process the linked resource] given el, success, and response.