个性化阅读
专注于IT技术分析

从wordpress网站中删除type=”text/javascript”

点击下载

我有一个基于wordpress的网站, 在其中我需要删除html头中的脚本和样式的type =” text / javascript”和type =” text / css”。

我在wp_head()和其他文件中进行了搜索, 但实际上找不到确切的来源。

哪个文件具有此代码?


#1


尝试在你的functions.php上使用此代码

add_filter('style_loader_tag', 'remove_type_attr', 10, 2);
add_filter('script_loader_tag', 'remove_type_attr', 10, 2);

function remove_type_attr($tag, $handle) {
    return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
}
赞(0)
未经允许不得转载:srcmini » 从wordpress网站中删除type=”text/javascript”

评论 抢沙发

评论前必须登录!