How it it possible to disbale all WooCommerce scripts and styles, but keep wc-ajax=get_refreshed_fragments working?

admin2025-06-03  3

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I disabled all styles and scripts for certain pages using the following code:

remove_action( 'wp_enqueue_scripts', [ WC_Frontend_Scripts::class, 'load_scripts' ] );
remove_action( 'wp_print_scripts', [ WC_Frontend_Scripts::class, 'localize_printed_scripts' ], 5 );
remove_action( 'wp_print_footer_scripts', [ WC_Frontend_Scripts::class, 'localize_printed_scripts' ], 5 );

As the question implies, the only thing, which has now disappeared, I want to keep working is the XHR AJAX calls to wc-ajax=get_refreshed_fragments. Is there any way to do this?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I disabled all styles and scripts for certain pages using the following code:

remove_action( 'wp_enqueue_scripts', [ WC_Frontend_Scripts::class, 'load_scripts' ] );
remove_action( 'wp_print_scripts', [ WC_Frontend_Scripts::class, 'localize_printed_scripts' ], 5 );
remove_action( 'wp_print_footer_scripts', [ WC_Frontend_Scripts::class, 'localize_printed_scripts' ], 5 );

As the question implies, the only thing, which has now disappeared, I want to keep working is the XHR AJAX calls to wc-ajax=get_refreshed_fragments. Is there any way to do this?

Share Improve this question asked Feb 7, 2019 at 13:45 manifestormanifestor 3136 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

If you look how that script is loaded in WC core

    'wc-cart-fragments'          => array(
        'src'     => self::get_asset_url( 'assets/js/frontend/cart-fragments' . $suffix . '.js' ),
        'deps'    => array( 'jquery', 'js-cookie' ),
        'version' => WC_VERSION,
    ),

You'll see the path to that script, as well as it's dependencies. rebuild that path and enqueue it yourself. FYI $suffix is set like this:

$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748934849a314955.html

最新回复(0)