Support » Plugin: WooCommerce » Prevent from PhotoSwipe being loaded two times after activation of WooCommerce

  • I am developing theme, which is using PhotoSwipe library for lightbox feature. Latest WooCommerce is using the same library, so it is loaded two times. What is the best practice to keep the lightbox feature on WooCommece, but just prevent from loading js code of PhotoSwipe second time (added by WooCommerce)?

    I have read about remove_theme_support( 'wc-product-gallery-lightbox' ); , but I want to keep the slider feature and just remove the PhotoSwipe library (already loaded with theme files).

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • If the JavaScript were enqueued using the same handle (see https://developer.wordpress.org/reference/functions/wp_enqueue_script/) it would only load the library one time. The handles used by WooCommerce are photoswipe and photoswipe-ui-default – if the theme uses those same handles to load the library, it would only be loaded once.

    Theme is adding all js scripts (included PhotoSwipe) in minified file with different handle, so in this case should I use the following code?

    <?php wp_deregister_script( 'photoswipe' );
    wp_deregister_script( 'photoswipe-ui-default' );?>

    Thanks!

    Plugin Support Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi there!

    Yes, that should do it!

    Have you had a chance to give it a go, to see if that resolves the issue?

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.