Bug 234094

Summary: Layered @import rules in <style> should be preloaded
Product: WebKit Reporter: Xiaocheng Hu <xiaochengh>
Component: CSSAssignee: Antti Koivisto <koivisto>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, dino, esprehn+autocc, ews-watchlist, gyuyoung.kim, koivisto, webkit-bug-importer, xiaochengh
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 220779    
Attachments:
Description Flags
layered imports not preloaded
none
Patch
none
Patch
none
Patch none

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].