Created
March 31, 2021 16:42
-
-
Save jtsternberg/2456a42a80d683f3bdd0ee06eda170ce to your computer and use it in GitHub Desktop.
Add defer tag to OM plugin embed scripts
This file contains hidden or 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
<?php | |
add_filter( 'optin_monster_api_final_output', function( $campaigns ) { | |
if ( ! empty( $campaigns ) ) { | |
foreach ( $campaigns as $slug => $embed ) { | |
$campaigns[ $slug ] = str_replace( 's.async=true;', 's.async=true;s.defer=true;', $embed ); | |
} | |
} | |
return $campaigns; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment