@krystianergotopia The reason for that is that historically, it’s been unreliable to detect shortcode usage in theme templates, custom plugins, widgets, etc.
But 2 things…
1) There is a workaround if you’re willing to add a bit of custom code. See https://github.com/moonstonemedia/WP-Simple-Pay-Snippet-Library/blob/master/conditionally-dequeue-scripts-styles.php and https://docs.wpsimplepay.com/articles/code-snippet-library/
2) It’s on our feature list to do exactly what you stated by default, but add an option to allow loading on every page when there’s an issue.
-
This reply was modified 8 years, 2 months ago by
Phil Derksen.
-
This reply was modified 8 years, 2 months ago by
Phil Derksen.
I tried it with this code to dequeue your script and the oneclick-upsell script from woocurve (they use also stripe). Its working for woocurve but your scripts are still loading on every page. How do I have to adjust this code?
function is_handsome_checkout(){
if( get_post_type() == ‘handsome-checkout’ ){
return true;
}
return false;
}
//add_action( ‘wp_enqueue_scripts’, ‘wc_dequeue_scripts’, 10 );
add_action( ‘wp_footer’, ‘wc_dequeue_scripts’, 10 );
function wc_dequeue_scripts() {
if ( ! is_checkout() && ! is_account_page() && ! is_handsome_checkout() ) {
wp_dequeue_script( ‘stripe’ );
wp_dequeue_script( ‘ocustripe’ );
}
}