I'm creating a theme and i want to upload it to envato. I have a javascript file that is type module and i can enqueue it and then use script_loader_tag filter to add type module to it by these lines.
wp_enqueue_script( 'slider-js', get_stylesheet_directory_uri() . '/src/js/slider.js', array(), time(), true );
add_filter( 'script_loader_tag', 'add_type_attribute', 10, 3 );
function add_type_attribute( $tag, $handle, $src ) {
if ( 'slider-js' !== $handle ) {
return $tag;
}
$tag = '<script type="module" src="' . esc_url( $src ) . '"></script>';
return $tag;
}
but the problem is when i run envato theme check and it gives this error:
REQUIRED: Found script_loader_tag in the file functions.php. Do not remove core functionality. Line 137: add_filter( 'script_loader_tag', 'add_type_attribute', 10, 3 );
Is there any other way to add type module ?