<link rel = preload>可以在<iframe>内预加载资源吗?


I have a page that embeds another page, let’s call it frame.html:

<iframe src="sub-page.html">

On sub-page.html, it loads some CSS and an image:

<link rel="stylesheet" href="sub-page.css">
<img src="sub-page.svg" alt="Sub-Page">

I at first thought that I could speed up the loading of these sub-subresources by adding <link rel=preload> to frame.html:

<link rel="preload" href="sub-page.css" as="style">
<link rel="preload" href="sub-page.svg" as="image">


The specs for preload links seem to emphasize that it’s only for subresources of the current page, but since you can preload font files that are called from a stylesheet, it’s plausible that resources of a frame could also count. Am I missing something, like the correct use of the crossorigin attribute?

  • 回复



    <link rel=preload> absolutely can preload subresources of an <iframe>’d page..