Created
November 15, 2024 13:36
-
-
Save erikmolenaarnl/cf9d480efb8419d07fbb0bdf329418e6 to your computer and use it in GitHub Desktop.
Exclude Mediavine JS script from being optimized (e.g. minified, combined or deferred) by the SG Optimizer plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Exclude Mediavine JS script from being optimized (e.g. minified, combined or deferred) by the SG Optimizer plugin | |
*/ | |
add_filter( 'sgo_js_minify_exclude', 'emd_exclude_mv_scripts_handles' ); | |
add_filter( 'sgo_javascript_combine_exclude', 'emd_exclude_mv_scripts_handles' ); | |
add_filter( 'sgo_js_async_exclude', 'emd_exclude_mv_scripts_handles' ); | |
function emd_exclude_mv_scripts_handles( $exclude_list ) { | |
$exclude_list[] = 'mv-control-panel'; | |
return $exclude_list; | |
} | |
// Additional fallback for JS IDs | |
add_filter( 'sgo_javascript_combine_exclude_ids', 'emd_exclude_mv_scripts_ids' ); | |
function emd_exclude_mv_scripts_ids( $exclude_list ) { | |
$exclude_list[] = 'mv-script-wrapper-js'; | |
return $exclude_list; | |
} | |
// Additional fallback filter for external JS paths | |
add_filter( 'sgo_javascript_combine_excluded_external_paths', 'emd_exclude_mv_scripts_external' ); | |
function emd_exclude_mv_scripts_external( $exclude_list ) { | |
$exclude_list[] = 'scripts.mediavine.com'; | |
return $exclude_list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment