admin管理员组文章数量:1130349
Theme check plugin gives me this error
Found script_loader_tag in the file functions.php. Do not remove core functionality.
I have used it to defer scripts
function add_defer_attribute($tag, $handle) {
$scripts_to_defer = array(
'jquery_table_js',
'searchautocompleter',
'jquery-migrate',
);
if (in_array($handle, $scripts_to_defer)) return str_replace(' src', ' defer="defer" handeler="'.$handle.'" src', $tag);
return str_replace(' src', ' handeler="'.$handle.'" src', $tag);
}
add_filter('script_loader_tag', 'add_defer_attribute', 100, 2);
this works fine but seems not allowed to do so.
Theme check plugin gives me this error
Found script_loader_tag in the file functions.php. Do not remove core functionality.
I have used it to defer scripts
function add_defer_attribute($tag, $handle) {
$scripts_to_defer = array(
'jquery_table_js',
'searchautocompleter',
'jquery-migrate',
);
if (in_array($handle, $scripts_to_defer)) return str_replace(' src', ' defer="defer" handeler="'.$handle.'" src', $tag);
return str_replace(' src', ' handeler="'.$handle.'" src', $tag);
}
add_filter('script_loader_tag', 'add_defer_attribute', 100, 2);
this works fine but seems not allowed to do so.
本文标签: theme developmentAlternative solution for scriptloadertag
版权声明:本文标题:theme development - Alternative solution for script_loader_tag? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749081672a2313141.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论