WordPress在有内置的 wp_script_add_data 与 wp_style_add_data 实现注册有条件的 javascript 和 css。可以通过这个来做IE浏览器兼容的识别。
IE 9一下增加 html5 shiv
// Load the html5 shiv.
wp_enqueue_script( 'html5', 'https://unpkg.com/html5shiv@3.7.3/dist/html5shiv.min.js', array(), null );
wp_script_add_data( 'html5', 'conditional', 'lt IE 9' );
解析后:
IE 8与IE 8以下增加css
// Load the Pure.css base.
wp_enqueue_style( 'base', 'https://unpkg.com/purecss@1.0.0/build/base-min.css',array(),null);
wp_style_add_data( 'base', 'conditional', 'lte IE 8' );
解析后:
参考资料:
分享到: