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

  • Resolved wpuser10

    (@wpuser10)


    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 4 replies - 1 through 4 (of 4 total)
  • Plugin Support wbrubaker

    (@wbrubaker)

    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!

    Plugin Support Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Howdy!

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.

    Cheers!

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