• Resolved Web Expert

    (@seldimi)


    Hello.
    Can you remove the text/javascript declaration from class-wc-abstract-google-analytics-js.php from line 51 or enqueue it with core’s inline script actions? According to HTML5 and html validator
    “The type attribute is unnecessary for JavaScript resources”.

    You enqueue the above script by echoing it, so the below function cannot affect it

       'after_setup_theme',
        function() {
            add_theme_support( 'html5', [ 'script', 'style' ] );
        }

    Same applies to class-wc-google-analytics-js.php at 104, 175 and class-wc-google-analytics.php 414

    A workaround could be something like the below:

    	$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
    	?>
    	<script<?php echo $type_attr; ?>>
    	// ....
    	</script>
    • This topic was modified 3 years, 3 months ago by Web Expert.
    • This topic was modified 3 years, 3 months ago by Web Expert.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Remove text/javascript’ is closed to new replies.