Title: async loading script
Last modified: December 3, 2024

---

# async loading script

 *  [Rhand](https://wordpress.org/support/users/rhand/)
 * (@rhand)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/async-loading-script/)
 * Wonder if there is an option to load script(s) async for better speed on load.
   Got this console warning load ing the site in Safari:
 *     ```wp-block-code
       Google Maps JavaScript API has been loaded directly without loading=async. This can result in suboptimal performance. For best-practice loading patterns please see https://goo.gle/js-api-loading
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fasync-loading-script%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Thread Starter [Rhand](https://wordpress.org/support/users/rhand/)
 * (@rhand)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/async-loading-script/#post-18200045)
 * Besides async loading conditionally loading would be great too. Seems all Maps
   JS is loaded even when we do not use the map
 *     ```wp-block-code
       <link rel="dns-prefetch" href="//maps.googleapis.com">...<link rel="stylesheet" id="bootstrap-css-css" href="https://domain.nl/wp-content/plugins/wd-google-maps/css/bootstrap.css?ver=1.0.64" type="text/css" media="all"><link rel="stylesheet" id="frontend_main-css-css" href="https://domain.nl/wp-content/plugins/wd-google-maps/css/frontend_main.css?ver=1.0.64" type="text/css" media="all">..<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places%2Cgeometry&amp;v=3.exp&amp;language=de&amp;key=xxxxxxxxxx-A&amp;ver=6.6.2" id="gmwd_map-js-js"></script><script type="text/javascript" src="https://domain.nl/wp-content/plugins/wd-google-maps/js/init_map.js?ver=1.0.64" id="frontend_init_map-js-js"></script><script type="text/javascript" src="https://domain.nl/wp-content/plugins/wd-google-maps/js/frontend_main.js?ver=1.0.64" id="frontend_main-js-js"></script>
       ```
   
 * But we may apply something like
 *     ```wp-block-code
       function dequeue_google_maps_assets() {    // List of page/post IDs or slugs where you want to dequeue    $excluded_pages = array(        123, // Replace with actual page/post ID        'your-page-slug', // Replace with page slug    );    // Check if the current page is in the excluded list    if (is_page($excluded_pages) || is_single($excluded_pages)) {        wp_dequeue_style('bootstrap-css-css');        wp_dequeue_style('frontend_main-css-css');        wp_dequeue_script('gmwd_map-js-js');        wp_dequeue_script('frontend_init_map-js-js');        wp_dequeue_script('frontend_main-js-js');    }}add_action('wp_enqueue_scripts', 'dequeue_google_maps_assets', 20);
       ```
   
    -  This reply was modified 1 year, 5 months ago by [Rhand](https://wordpress.org/support/users/rhand/).
    -  This reply was modified 1 year, 5 months ago by [Rhand](https://wordpress.org/support/users/rhand/).

Viewing 1 replies (of 1 total)

The topic ‘async loading script’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wd-google-maps_9eaba3.svg)
 * [10Web Map Builder for Google Maps](https://wordpress.org/plugins/wd-google-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wd-google-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wd-google-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/wd-google-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wd-google-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wd-google-maps/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Rhand](https://wordpress.org/support/users/rhand/)
 * Last activity: [1 year, 5 months ago](https://wordpress.org/support/topic/async-loading-script/#post-18200045)
 * Status: not resolved