Title: &#8220;dequeue&#8221; styles and scripts for frontend optimisation?
Last modified: May 31, 2023

---

# “dequeue” styles and scripts for frontend optimisation?

 *  Resolved [Mahesh Thorat](https://wordpress.org/support/users/maheshmthorat/)
 * (@maheshmthorat)
 * [3 years ago](https://wordpress.org/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/)
 * Hi [WP Go Maps (formerly WP Google Maps)](https://wordpress.org/plugins/wp-google-maps/)
   team, hope you all doing well.
 * Recently I am using this plugin for integrating maps. But I have seen there are
   so many scripts and styles loaded in frontend and I don’t think that default 
   methods are able to block them. 
   I have tried below code :
 *     ```wp-block-code
       function dequeue_wp_google_maps_styles_scripts() {
           wp_dequeue_style('fontawesome');
           wp_dequeue_style('datatables');
           wp_dequeue_style('wpgmaps_datatables_responsive-style');
   
       	wp_dequeue_script('datatables');
       	wp_dequeue_script('datatables-responsive');
           wp_dequeue_script('javascript-cookie');
       }
       add_action('wp_enqueue_scripts', 'dequeue_wp_google_maps_styles_scripts', 9999999);
       ```
   
 * Initially may be need to control for better performance of frontend I don’t required
   some part like fontawesome, datatables and so on…
   So please let me know how to
   get it done.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [DylanAuty](https://wordpress.org/support/users/dylanauty/)
 * (@dylanauty)
 * [3 years ago](https://wordpress.org/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/#post-16783214)
 * Hi [@maheshmthorat](https://wordpress.org/support/users/maheshmthorat/),
 * Thank you for getting in touch, we do appreciate your time.
 * Although you can use standard hooks for dequeue calls, we usually advise instead
   using our dedicated developer hooks to manage these kinds of calls, as this ensures
   your load order will be respected as part of our initialization loops.
 * For example, your dequeue script would be written like this instead:
 *     ```wp-block-code
       function wpgmza_dequeue_non_essential_dependencies($deps){
   
           $dequeue = array('datatables', 'datatables-responsive', 'javascript-cookie');
   
           foreach($dequeue as $dep){
   
               if(!empty($deps[$dep])){
   
                   unset($deps[$dep]);
   
               }
   
           }
   
           return $deps;
   
       }
   
       add_filter('wpgmza-get-library-dependencies', 'wpgmza_dequeue_non_essential_dependencies');
   
       function wpgmza_dequeue_non_essential_styles(){
   
           wp_dequeue_style('datatables');
   
           wp_dequeue_style('wpgmaps_datatables_responsive-style');
   
           wp_dequeue_style('fontawesome');
   
       }
   
       add_action('wpgmza_script_loader_enqueue_styles', 'wpgmza_dequeue_non_essential_styles', 9999);
       ```
   
 * You can learn more about our hooks, in our documentation: [https://docs.wpgmaps.com/hooks](https://docs.wpgmaps.com/hooks)
 * I hope this helps?
 *  Thread Starter [Mahesh Thorat](https://wordpress.org/support/users/maheshmthorat/)
 * (@maheshmthorat)
 * [3 years ago](https://wordpress.org/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/#post-16784863)
 * Hi [@dylanauty](https://wordpress.org/support/users/dylanauty/) thank you so 
   much for your response. Appreciate the hooks provided by you.
 * > Q1. In that case it’s not able to restrict some **js css **in frontend as below.
 * **CSS**
    1. _wpgmaps\_datatables\_responsive-style_
    2. featherlight
    3. owl-carousel_style
    4. owl-carousel_style__default_theme
    5. owl_carousel_style_theme_select
 * **JS**
    1. featherlight
 * > Q2.Also I noticed in my head tag there are some external scripts attached from
   > googleapis can I control that also from hooks?
 * ![](https://i0.wp.com/i.stack.imgur.com/y4Glb.png?ssl=1)
 * > Q3. Also if possible can we get the lazy load feature for that because most
   > of cases we use maps globally or on home page so its very laggy sometimes. 
   > If also able to make this for pro version that would fine. But we need lazy
   > loading maps for better page speed.
 * Thanks,
   **Mahesh Thorat**
 *  Plugin Author [DylanAuty](https://wordpress.org/support/users/dylanauty/)
 * (@dylanauty)
 * [3 years ago](https://wordpress.org/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/#post-16784928)
 * Hi [@maheshmthorat](https://wordpress.org/support/users/maheshmthorat/),
 * Only a pleasure, happy to help where I can. Please find further responses below,
   in order:
    1. This may be true, for some modules for various reasons. **Owl Carousel** assets
       can simply be disabled in the settings area. **Maps > Settings > Marker Listings
       > Dependencies.** The additional modules you mentioned are not core dependencies,
       and as such can instead be dequeued when the map is prepared for initialization,
       with this additional hook:
 *     ```wp-block-code
       function wpgmza_dequeue_additional_dependencies(){
           wp_dequeue_style('featherlight');
           wp_dequeue_script('featherlight');
           wp_dequeue_style('wpgmaps_datatables_responsive-style');
       }
   
       add_action('wpgooglemaps_hook_user_js_after_core', 'wpgmza_dequeue_additional_dependencies', 9999);
       ```
   
 * 2. These additional scripts are all controlled directly by the Google Maps API,
   that is to say we simply include the API, with your appropriate API key and once
   verified, Google loads those additional scripts to support their API core.
 * 3. Delayed, deferred, async and lazyloading is all supported in full. We do not
   offer this as a setting but integrate with plugins like LS Cache, WP Rocket, 
   Async JavaScript which means you can enable most script optimization plugins,
   which support delayed loading, and see the addition of those tags in our inclusions.
 * I hope that helps.
 *  Thread Starter [Mahesh Thorat](https://wordpress.org/support/users/maheshmthorat/)
 * (@maheshmthorat)
 * [3 years ago](https://wordpress.org/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/#post-16784962)
 * Thanks [@dylanauty](https://wordpress.org/support/users/dylanauty/) appreciate
   your time spent for the thread. Worked settings as per you provided. 
   Also appreciate
   the plugin is just awesome helped so many complex structures and saved so many
   hours of coding. Thanks again.
 * Thanks,
   **Mahesh Thorat**
 *  Plugin Author [DylanAuty](https://wordpress.org/support/users/dylanauty/)
 * (@dylanauty)
 * [3 years ago](https://wordpress.org/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/#post-16785004)
 * My pleasure [@maheshmthorat](https://wordpress.org/support/users/maheshmthorat/)–
   Glad I could help.
 * Have a great day.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘“dequeue” styles and scripts for frontend optimisation?’ is closed to
new replies.

 * ![](https://ps.w.org/wp-google-maps/assets/icon-256x256.png?rev=3058363)
 * [WP Go Maps - Google Maps, OpenStreetMap, Leaflet Map](https://wordpress.org/plugins/wp-google-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-google-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-google-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-google-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-google-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-google-maps/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [DylanAuty](https://wordpress.org/support/users/dylanauty/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/dequeue-styles-and-scripts-for-frontend-optimisation/#post-16785004)
 * Status: resolved