代码之家  ›  专栏  ›  技术社区  ›  anjanesh

在正文中包含预取链接,而不是页眉

  •  0
  • anjanesh  · 技术社区  · 5 年前

    我想在我的WordPress页面中包含mydomain.com/plan,其page_id=25:

    <link rel="prefetch" href="/plan-both/ " as="document">
    <link rel="prefetch" href="/plan-strategy/ " as="document">
    <link rel="prefetch" href="/plan-funding/ " as="document">
    

    根据 this 我们需要将其包含在header.php文件中:

    <?php if(is_page(25)) { ?>
        <link rel="prefetch" href="/plan-both/ " as="document">
    <?php } ?>
    

    提问 :如果我包含在页面正文中,预取仍然有效吗?
    这样我就可以在WordPress页面中包含它,而不是编辑header.php文件。

    0 回复  |  直到 5 年前
        1
  •  1
  •   Thomas Theunen    5 年前

    是的,预取仍然有效。

    它还将略微提高页面加载性能,因为如果页面位于头部,预取将在页面加载的中途开始。

    把它移到底部,只有在所有重要的事情都完成之后,它才会开始。

    推荐文章