• Resolved Andrew

    (@antrikos)


    I was wondering if you could help out with this error which pops up on the w3 validation process.

    Error: A script element with a src attribute must not have a type attribute whose value is anything other than the empty string, a JavaScript MIME type, or module.

    <script src="https://***/wp-content/cache/autoptimize/js/autoptimize_56420dbce3d3718307457b6a97bc1b1d.js" type="2b60ab97d3903600004a1f49-text/javascript">

    <script src='https://***/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp' id='jquery-core-js' type="2b60ab97d3903600004a1f49-text/javascript">

    I already tried out the following solution, without positive results

    if ( ! function_exists( 'prefix_remove_type_attr' ) ) {
    
    	function prefix_remove_type_attr( $tag ) {
    		return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag );
    	}
    
    	add_filter( 'style_loader_tag', 'prefix_remove_type_attr', 10 );
    	add_filter( 'script_loader_tag', 'prefix_remove_type_attr', 10 );
    	add_filter( 'autoptimize_html_after_minify', 'prefix_remove_type_attr', 10 ); 
    }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘W3C Validation’ is closed to new replies.