mirror of
https://github.com/RGBCube/serenity
synced 2025-07-07 20:47:34 +00:00
LibWeb: Preload resources hinted by <link rel="preload">
If a page is nice enough to give us some preload hints, we can tell RequestServer to get started on downloading the resources right away, instead of waiting until discovering them later on during parsing.
This commit is contained in:
parent
ed5c807c99
commit
5bb2e6597a
2 changed files with 12 additions and 0 deletions
|
@ -36,6 +36,13 @@ void HTMLLinkElement::inserted()
|
|||
if (auto sheet = m_css_loader.style_sheet())
|
||||
document().style_sheets().add_sheet(sheet.release_nonnull());
|
||||
}
|
||||
|
||||
if (m_relationship & Relationship::Preload) {
|
||||
// FIXME: Respect the "as" attribute.
|
||||
LoadRequest request;
|
||||
request.set_url(attribute(HTML::AttributeNames::href));
|
||||
m_preload_resource = ResourceLoader::the().load_resource(Resource::Type::Generic, request);
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLLinkElement::parse_attribute(const FlyString& name, const String& value)
|
||||
|
@ -48,6 +55,8 @@ void HTMLLinkElement::parse_attribute(const FlyString& name, const String& value
|
|||
m_relationship |= Relationship::Stylesheet;
|
||||
else if (part == "alternate")
|
||||
m_relationship |= Relationship::Alternate;
|
||||
else if (part == "preload")
|
||||
m_relationship |= Relationship::Preload;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue