Created
June 3, 2020 18:17
-
-
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
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 // 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