Anonymous User 16850768
(@anonymized-16850768)
To troubleshoot this, can you please provide the snippet used in your functions.php file?
add_action('wp_loaded', 'prefix_output_buffer_start');
function prefix_output_buffer_start() {
ob_start("prefix_output_callback");
}
add_action('shutdown', 'prefix_output_buffer_end');
function prefix_output_buffer_end() {
ob_end_flush();
}
function prefix_output_callback($buffer) {
return preg_replace( "%[ ]type=[\'\"]text\/(javascript|css)[\'\"]%", '', $buffer );
}
Anonymous User 16850768
(@anonymized-16850768)
The easiest way to make this work in my opinion would be using the Cache Enabler cache_enabler_before_store filter, for example:
// hook callback function with Cache Enabler action
add_filter( 'cache_enabler_before_store', 'prefix_output_callback' );
// remove JS/CSS type attribute on script and source elements
function prefix_output_callback( $data ) {
return preg_replace( '%[ ]type=[\'\"]text\/(javascript|css)[\'\"]%', '', $data );
}
This will allow Cache Enabler to call your custom function (passing the page data as $data) and then receive the modified page data before the page is cached.
Cool, it is working, thanks you