wp_dequeue in functions.php custom code, kills the plugin

Home Forums Store Locator Plus wp_dequeue in functions.php custom code, kills the plugin

This topic contains 1 reply, has 2 voices, and was last updated by  Lance Cleveland 2 years, 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22397

    fortfort
    Participant

    After a long time of searching, i found why i need to forse load the javascript,  if i dont add !is_page(‘praktijken’) (where the slp, code is on) so somehow dequeue ing kills the normal working of your plugin lance, i think more people have problems with this, and could help you:

     

    // remove woocommerce scripts on unnecessary pages

    function woocommerce_de_script() {

    if (function_exists( ‘is_woocommerce’ )) {

    if (!is_woocommerce() && !is_cart() && !is_checkout() && !is_account_page() && !is_page(‘praktijken’) ) { // if we’re not on a Woocommerce page, dequeue all of these scripts

    wp_dequeue_script(‘wc-add-to-cart’);

    wp_dequeue_script(‘jquery-blockui’);

    wp_dequeue_script(‘jquery-placeholder’);

    wp_dequeue_script(‘woocommerce’);

    wp_dequeue_script(‘jquery-cookie’);

    wp_dequeue_script(‘wc-cart-fragments’);

    }

    }

    }

    #23100

    Lance Cleveland
    Keymaster

    Other scripts that break or throw errors will cause any scripts that follow, including SLP scripts, to break.    The problem is that there is no easy solution that I’m aware of to dequeue all other bad scripts that may be out there.

    I could easily add an “if a SLP locator is on this page dequeue X, Y, Z” scripts like the list you have above but that can break other functionality of those plugins.    On my site I avoid using any sidebar or menu widgets that load poorly-written JavaScript.   That means no shopping carts, etc. on the sidebar of my locator pages.     It reduces the chances of a script conflict as long as the plugins are following best practices and not doing the “load our script on EVERY page on the site even if it is not needed” implementation.

    I will think about this and see if maybe adding a “dequeue these scripts on pages where the map is displayed” setting would make sense.   Possibly under general settings where “force load JavaScript” lives.

    Being able to leave Force Load JavaScript OFF is a HUGE benefit on SLP sites.    More SLP features work properly and the SLP script is not loaded on every page on the site which makes the site a little faster for your visitors.

    Thanks for the input.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.