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