Completely Disable Map Services

If you care about website performance and easier administration, I recommend using a code snippet plugin like WPCodeBox (or similar) for adding code to your website.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

By default, Google Maps is selected under Theme Tools > Map Services, which is a contributing factor to slowing down your website. In this case, MyListing performs a dns-prefetch to Google’s API, which is an external lookup, even if you have not configured the Google Maps settings.

This is NOT something specific to Google Maps. If you happen to toggle on MapBox or OpenStreetMap without configuring it, the same outcome would occur.

What’s the Big Deal?

When you prefetch anything on your website, you are telling it to make a DNS lookup for an asset or service that will be needed at some point during a page load. If the DNS lookup is needed, that’s fine, but if not, you’re deprioritizing other parts of your site that actually need that DNS lookup or need to load.

In layman’s terms, we would rather not waste time talking to someone if they aren’t going to help. Instead, we want to ignore them and talk to the people who do want to help.

How to Test

If you want to test your site, you can use this free tool (website) by simply entering your website URL.

PHP
add_action( 'wp_enqueue_scripts', function() {
 wp_dequeue_script( 'mylisting-google-maps' );
 wp_dequeue_script( 'google-maps' );
 wp_dequeue_style( 'mylisting-google-maps' );
 wp_dequeue_script( 'mylisting-mapbox' );
 wp_dequeue_script( 'mapbox-gl' );
 wp_dequeue_style( 'mapbox-gl' );
}, 99 );

🔥NEW!🔥
Property Starter Site
MyListing Add-on
Launch Sale Ends: June 24th.

Club Guarantee

If you notice an issue with this product, I’ll fix it for free and get you an updated version.

Club Guarantee

If you notice an issue with a Club Product and the problem exists on the corresponding Starter Site, I’ll fix it for free.