[wp-trac] [WordPress Trac] #42804: type is not required in HTML5

WordPress Trac noreply at wordpress.org
Sun Jun 30 11:25:16 UTC 2019


#42804: type is not required in HTML5
-------------------------------------+-----------------------------
 Reporter:  sasiddiqui               |       Owner:  (none)
     Type:  enhancement              |      Status:  new
 Priority:  low                      |   Milestone:  Future Release
Component:  Script Loader            |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  needs-testing has-patch  |     Focuses:
-------------------------------------+-----------------------------

Comment (by daymobrew):

 Replying to [comment:18 gabrieldiggs]:
 > EDIT: Added the following function to my theme functions.php and the W3C
 validation errors are gone. Is this the right way to fix the issue?
 >
 > {{{
 > //Remove JS and CSS types
 >
 > add_action( 'template_redirect', function(){
 >     ob_start( function( $buffer ){
 >         $buffer = str_replace( array( 'type="text/javascript"',
 "type='text/javascript'", 'type="text/css"', "type='text/css'" ), '',
 $buffer );
 >
 >         return $buffer;
 >     });
 > });
 > }}}
 >
 I did something similar: https://www.damiencarbery.com/2018/11/remove-
 type-from-script-and-style-markup/
 I filtered 'script_loader_tag' and 'style_loader_tag' to work on enqueued
 scripts and styles and used ob_start() and ob_get_contents() on 'wp_head'
 to process inline scripts and styles.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42804#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list