我在网页上为字体添加了一些预加载标签,并且这些字体运行正常,除了字体真棒。
从代码中可以看到,我添加了所有用于字体预加载的必要属性
<link rel="preload" href="<?php bloginfo('template_directory') ?>/css/fonts.css" as="style" type="text/css" crossorigin="anonymous">
<link rel="preload" href="<?php bloginfo('template_directory') ?>/fonts/RobotoBlack.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="<?php bloginfo('template_directory') ?>/fonts/RobotoRegular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="<?php bloginfo('template_directory') ?>/fonts/RobotoMedium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="<?php bloginfo('template_directory') ?>/fonts/RobotoLight.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="<?php bloginfo('template_directory') ?>/css/font-awesome.min.css" as="style" type="text/css" crossorigin="anonymous">
<link href="<?php bloginfo('template_directory') ?>/css/font-awesome.min.css" rel="stylesheet" type="text/css" as="style" crossorigin="anonymous"/>
<link rel="preload" href="<?php bloginfo('template_directory') ?>/fonts/fontawesome-webfont.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link href="<?php bloginfo('template_directory') ?>/css/fonts.css" rel="stylesheet" type="text/css" crossorigin="anonymous"/>
但是Chrome控制台仅针对FontAwesome发出警告。
资源http://webTest.test/wp-content/themes/myTheme/fonts/fontawesome-webfont.woff2已使用链接预加载进行了预加载,但在窗口加载事件发生后的几秒钟内未使用。请确保它具有适当的
as
值并且已被有意地预加载。
我做错了什么?如果有帮助,我将不胜感激。