[wp-trac] [WordPress Trac] #43111: W3C validation warnings: type attribute

WordPress Trac noreply at wordpress.org
Wed Jan 17 15:43:54 UTC 2018


#43111: W3C validation warnings: type attribute
--------------------------+-----------------------------
 Reporter:  ArtGoddess    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.9.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hello,

 After deactivating all plugins and switching to Twenty Seventeen theme, I
 can see a huge quantity of warnings.

 The type attribute is unnecessary for JavaScript resources.

 and

 The type attribute for the style element is not needed and should be
 omitted.

 After a Google search, I have found some pages that provide useful
 functions for get rid of the type attribute.

 https://www.lee-harris.co.uk/blog/remove-type-attribute-script-tags-
 wordpress/

 https://wordpress.stackexchange.com/questions/287830/remove-type-
 attribute-from-script-and-style-tags-added-by-wordpress

 https://stackoverflow.com/questions/47906924/remove-type-attribute-from-
 script-and-style-tags-in-wordpress

 The fact is that none of the presented functions remove all the
 type=”text/javascript” and type=”text/css”, for some factors. For example,
 how scripts and styles are enqueued, or if they use single or double
 quotes.

 wp-includes\class.wp-scripts.php

 $tag = "{$cond_before}{$before_handle}<script type='text/javascript'
 src='$src'></script>\n{$after_handle}{$cond_after}";

 Also wp-includes\class.wp-styles.php adds the type=’text/css’ attribute.

 Even if I delete the type='text/javascript' from line 327 I can see that
 default WP Emojis javascript and css style, use type=”text/css” and
 type=”text/javascript”.

 I have two questions:

 1. Has WordPress any plan to get rid of these warnings in order to follow
 W3C guidelines?

 2. Can someone please provide a function in order to remove all these
 warnings? Please, if you don’t care about W3C warnings, do not reply to
 this post.

 Thank you.

 https://wordpress.org/support/topic/w3c-validation-warnings-type-
 attribute/

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43111>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list