1. Home
  2. /
  3. Forum

Forum

w3c and WCAG valida...
 
Notifications
Clear all

w3c and WCAG validation - Remove type attribute from style and script

3 Posts
1 Users
0 Reactions
642 Views
(@devsam)
Member Admin
Joined: 5 years ago
Posts: 18
Topic starter  

Remove type attribute from style and script in wordpress.

Add the following piece of script in your themes functions.php file

 

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

 

 


   
Quote
(@devsam)
Member Admin
Joined: 5 years ago
Posts: 18
Topic starter  
add_action( 'template_redirect', 'remove_type_attr' );
function remove_type_attr() {
ob_start( function ( $buffer ) {
return preg_replace( "%[ ]type=['\"]text\/(javascript|css)['\"]%", '', $buffer );
} );
}

   
ReplyQuote
(@devsam)
Member Admin
Joined: 5 years ago
Posts: 18
Topic starter  
add_action( 'template_redirect', 'remove_language_attr' );
function remove_language_attr() {
ob_start( function ( $buffer ) {
return preg_replace( "%[ ]language=['\"]JavaScript['\"]%", '', $buffer );
} );
}

   
ReplyQuote
Share:
Reviews & Ratings Get your stoe online with Shopify in 60 minutes Shop Now