【发布时间】:2018-03-08 07:30:21
【问题描述】:
过滤特定 css 文件的链接非常简单。但我想过滤除 style.css 之外的所有内容:add_filter( 'style_loader_tag', 'remove_https_http', 10, 4 ); 递归地提供优化的 css 和页面速度和加载时间的高分。
add_filter( 'style_loader_tag', 'remove_https_http', 10, 4 );
function remove_https_styles( $html, $handle, $href, $media ){
$handles = array('twentysixteen-fonts', 'open-sans');
if( in_array( $handle, $handles ) ){
$html = str_replace('https:', '', $html);
}
return $html;
}
如果有其他方法,那就太好了。我已经在学习:CSS delivery optimization: How to defer css loading?。但在我看来,过滤所有可以在渲染我的页面后加载的 css 链接,建议:https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-blocking-css。
任何想法都会是一个很好的工具提示。提前致谢。
【问题讨论】:
-
这既不是 HTML 也不是 CSS。是PHP吗? WordPress?
-
更新。谢谢。
标签: wordpress