Warning: The type attribute is unnecessary for JavaScript resources.
From line 10, column 146; to line 10, column 176
feed/" /> <script type="text/javascript">window
Warning: The type attribute for the style element is not needed and should be omitted.
From line 11, column 1798; to line 11, column 1820
</script> <style type="text/css">img.wp
Warning: The type attribute for the style element is not needed and should be omitted.
From line 23, column 193; to line 23, column 251
a='all' /><style id='kirki-styles-global-inline-css' type='text/css'>.envel
Warning: The type attribute is unnecessary for JavaScript resources.
From line 23, column 905; to line 23, column 1010
}</style> <script async type="text/javascript" src="http://....../wp-content/cache/minify/df983.js"></scri
Warning: The type attribute for the style element is not needed and should be omitted.
From line 70, column 126; to line 70, column 167
70.png" /><style type="text/css" id="wp-custom-css">@media
Warning: The type attribute is unnecessary for JavaScript resources.
From line 441, column 156; to line 441, column 261
iv></div> <script defer type="text/javascript" src="http://......./wp-content/cache/minify/26938.js"></scri
Warning: The type attribute is unnecessary for JavaScript resources.
From line 441, column 272; to line 441, column 302
</script> <script type='text/javascript'>/* */
Warning: The type attribute is unnecessary for JavaScript resources.
From line 443, column 17; to line 443, column 122
</script> <script defer type="text/javascript" src="http://......../wp-content/cache/minify/6ce07.js"></scri
这些错误是W3C的一些新引入,仅在最近的3-4天内开始出现。
我们将这样的脚本排队→
wp_register_script( 'custom-js', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '1.1', true );
wp_enqueue_script( 'custom-js' );
我们可以通过上述排队方法来解决此问题吗?
更新→
这些是实际的错误。在红色框中是来自W3的总缓存。
#1 楼
WordPress 5.3引入了一种相当简单的方法来实现这一目标。通过为script
和style
注册对HTML 5的主题支持,将省略type=""
属性:add_action(
'after_setup_theme',
function() {
add_theme_support( 'html5', [ 'script', 'style' ] );
}
);
评论
工作正常,谢谢。
–迈克尔·罗杰斯(Michael Rogers)
19/12/13在18:54
这是正确的方法。
– Ankit Chauhan
20年1月8日在6:13
好一个!这应该是公认的答案。
–乔
20年1月15日在15:10
wpbeginner.com/beginners-guide/…
–雅各布·皮蒂(Jacob Peattie)
20年5月21日在11:11
它不会使用wp-emoji-release.min.js从行中删除类型-
评论
对于Wordpress网站或任何流行的cms,W3C验证程序很少返回无错误的消息。每年的情况似乎越来越糟。验证器(imho)应该用作揭示一些基本错误的工具(例如忘记alt标签或忘记关闭标签),但不应再像以前那样被视为标准。他们在017年12月2日之后推出了它。在那之前,我的主题是错误/警告免费。应该有一些摆脱它们的方法。
查看script_loader_tag钩子,您也许可以执行str_replace()删除它们。
值得指出的是,这些只是警告,而不是错误。您的网站仍会验证。
您也可以检查以下答案-stackoverflow.com/a/53380692/2611955