【问题标题】:Preload Key Request for font files字体文件的预加载密钥请求
【发布时间】:2020-11-02 16:22:08
【问题描述】:

我在互联网上搜索过,如果我考虑做某事<link rel=preload>,它将解决问题。

但是我在我的代码文件中没有找到这些资源,谁能帮我找到这些文件的来源以便我可以修改它们?

My Website

注意:我使用的是 wordpress 网站,主题名称是 kuteshop,如果您想查看任何其他文件,请告诉我。

期待听到您的宝贵意见。

谢谢!

【问题讨论】:

    标签: wordpress testing performance-testing web-performance


    【解决方案1】:

    在我的 wordpress function.php 中添加以下代码解决了这个问题。

    function font_preload() {
                    
                     echo '<link rel="preload" href="http://mywebsite.org/wp-content/themes/kuteshop/assets/fonts/Pe-icon-7-stroke.woff?d7yf1v" as="font" crossorigin="anonymous">';
                      echo '<link rel="preload" href="http://mywebsite.org/wp-content/themes/kuteshop/assets/fonts/flaticon/Flaticon.woff" as="font" crossorigin="anonymous">';
                      
                      echo '<link rel="preload" href="https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmYUtfBBc4.woff2" as="font" crossorigin="anonymous">';
                      echo '<link rel="preload" href="https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmEU9fBBc4.woff2" as="font" crossorigin="anonymous">';
                      echo '<link rel="preload" href="https://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVs9pbCIPrE.woff2" as="font" crossorigin="anonymous">';
                      echo '<link rel="preload" href="https://fonts.gstatic.com/s/opensans/v18/mem8YaGs126MiZpBA-UFVZ0b.woff2" as="font" crossorigin="anonymous">';
                      
                      
                      
            }
            add_action('wp_head', 'font_preload', 0);
    

    【讨论】:

    • 您好,您是从哪里得知这件事的?请问可以分享资源吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    相关资源
    最近更新 更多