Wordpress plugin issue
Closed this issue · 1 comments
thewebartisan7 commented
Hi,
I notice that the filter add_attributes_to_script()
doesn't work because script tag has not the type attribute anymore in Wordpress, or almost in mine Wordpress with default theme TwentyTwenty and without any plugin. I see that this filter replace type="text/javascript" with type="module".
I solved by using below solution, which also add integrity:
add_filter('script_loader_tag', 'add_attributes_to_script', 10, 3);
function add_attributes_to_script( $tag, $handle, $src ) {
if ( 'instantpage' === $handle ) {
$tag = '<script src="' . esc_url( $src ) . '" type="module" integrity="sha384-by67kQnR+pyfy8yWP4kPO12fHKRLHZPfEsiSXR8u2IKcTdxD805MGUXBzVPnkLHw"></script>';
}
return $tag;
}
dieulot commented
This was fixed in the version 5.6.0 of the plugin. (It was triggered on themes using the HTML5 syntax option.)