• Resolved rose18

    (@rose18)


    Hi,

    We are trying to dequeue unnecessary styles and script on the front-end, and it’s not working for some.
    I followed this post: https://www.ads-software.com/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/

    I am trying to dequeue the scripts and styles below, but it’s not working when I use the ‘wpgooglemaps_hook_user_js_after_core’ hook or these other hooks (‘wpgmza-get-library-dependencies’ + ‘wpgmza_script_loader_enqueue_styles’)

    css:
    -featherlight
    -wpgmaps_datatables_responsive-style

    js:
    -featherlight
    -polyline
    -wpgmza_canvas_layer_options
    -wpgmza_canvas_layer

    what hooks should we use to dequeue those?

    thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author DylanAuty

    (@dylanauty)

    Hi @rose18,

    Thank you for getting in touch, we do appreciate your time.

    As all of the mentioned dependencies are non-essential (not core) modules, you only need to dequeue these using the ‘wpgooglemaps_hook_user_js_after_core’ hook, I’ve prepared a specific code block for you:

    function wpgmza_dequeue_additional_dependencies(){
    wp_dequeue_style('featherlight');
    wp_dequeue_script('featherlight');
    wp_dequeue_style('wpgmaps_datatables_responsive-style');
    wp_dequeue_script('wpgmza_canvas_layer_options');
    wp_dequeue_script('wpgmza_canvas_layer');
    wp_dequeue_script('polyline');
    }

    add_action('wpgooglemaps_hook_user_js_after_core', 'wpgmza_dequeue_additional_dependencies', 9999);

    This has been tested on my side and works as expected. If it is not working on your side, I’d need to know a bit more about how you’re adding this PHP to your site?

    We recommend adding it to the functions.php file of your child theme, to ensure it loads correctly to dequeue these assets.

    Thread Starter rose18

    (@rose18)

    @dylanauty thank you! but adding your code block still doesn’t work for me, the frontend is still loading those files.
    I added the code to my functions.php file in my child theme.

    Thread Starter rose18

    (@rose18)

    @dylanauty – Also to add, I have WP Go Maps Pro plugin installed, does that affect the code that you’ve provided? thanks!

    Plugin Author DylanAuty

    (@dylanauty)

    Hi @rose18,

    Thank you for getting back to me, I do appreciate it.

    That is quite strange as this same code has been used on many sites (including our own development sites) and works without issue. I suspect there may be some additional layer of functionality preventing our code from taking affect.

    Unfortunately we aren’t allowed to discuss any Premium features/questions via these threads, as per the www.ads-software.com guidelines.

    Would you mind opening a support ticket on our website instead so that someone from my team can work more closely with you on this to get it sorted?

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