Skip to content

Instantly share code, notes, and snippets.

@thomasplevy
Created June 3, 2020 18:17
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 thomasplevy/5b04ff841d3b18e0966ee878d3d14c25 to your computer and use it in GitHub Desktop.
Save thomasplevy/5b04ff841d3b18e0966ee878d3d14c25 to your computer and use it in GitHub Desktop.
Remove Stripe.js (as enqueued by the LifterLMS Stripe plugin) from pages where Stripe isn't explicitly required or used
<?php // Don't copy this line to your functions.php file!
/**
* Remove Stripe.js (as enqueued by the LifterLMS Stripe plugin) from pages where Stripe isn't explicitly required or used.
*
* Stripe *recommends* that you load Stripe.js on every site on your website
* to improve automatic fraud detection (https://stripe.com/docs/radar).
*
* You can use this code if you don't care about Radar / fraud detection
* to enjoy a small performance improvement.
*
* @since 2020-06-03
*
* @return void
*/
function my_stripe_dequeue() {
if ( function_exists( 'is_llms_checkout' ) && function_exists( 'is_llms_account_page' ) ) {
if ( ! is_llms_checkout() && ! is_llms_account_page() ) {
wp_dequeue_script( 'stripe' );
}
}
}
add_action( 'wp_enqueue_scripts', 'my_stripe_dequeue', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment