Bug 234094 - Layered @import rules in <style> should be preloaded
Summary: Layered @import rules in <style> should be preloaded
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Antti Koivisto
URL:
Keywords: InRadar
Depends on:
Blocks: 220779
  Show dependency treegraph
 
Reported: 2021-12-09 11:28 PST by Xiaocheng Hu
Modified: 2022-01-20 04:17 PST (History)
9 users (show)

See Also:


Attachments
layered imports not preloaded (493.72 KB, image/png)
2021-12-09 11:28 PST, Xiaocheng Hu
no flags Details
Patch (7.39 KB, patch)
2022-01-17 05:35 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
Patch (7.35 KB, patch)
2022-01-17 05:41 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff
Patch (7.53 KB, patch)
2022-01-17 05:42 PST, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xiaocheng Hu 2021-12-09 11:28:34 PST
Created attachment 446576 [details]
layered imports not preloaded

Test case: https://purring-various-felidae.glitch.me/css-import-preload-layer.html

It tests if the following CSS imports are preloaded:

<style>
  @import url('/stylesheet?delay=1001');
  @import url('/stylesheet?delay=1002') layer;
  @import url('/stylesheet?delay=1003') layer(foo);
</style>

(Here delay=foo means the request takes foo ms to finish)

All the three should be preloaded, but as I tested in Safari Technology Preview Release 135 (Safari 15.4, WebKit 17613.1.7.3), the two layered imports are not preloaded. They start loading only after the parser-blocking script have finished, as shown by the attached screenshot.

This will hurt the loading performance when using cascade layers, since @import is currently the only way to add an external stylesheet into a layer.
Comment 1 Radar WebKit Bug Importer 2021-12-16 11:29:18 PST
<rdar://problem/86586969>
Comment 2 Antti Koivisto 2022-01-17 05:35:46 PST
Created attachment 449326 [details]
Patch
Comment 3 Antti Koivisto 2022-01-17 05:41:17 PST
Created attachment 449328 [details]
Patch
Comment 4 Antti Koivisto 2022-01-17 05:42:16 PST
Created attachment 449330 [details]
Patch
Comment 5 EWS 2022-01-17 11:45:23 PST
Committed r288099 (246113@main): <https://commits.webkit.org/246113@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449330 [details].