Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Created March 31, 2021 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtsternberg/2456a42a80d683f3bdd0ee06eda170ce to your computer and use it in GitHub Desktop.
Save jtsternberg/2456a42a80d683f3bdd0ee06eda170ce to your computer and use it in GitHub Desktop.
Add defer tag to OM plugin embed scripts
<?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