NateWr / business-profile

WordPress plugin to display your business's contact details with seo-friendly Schema.org markup.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enqueue Google Maps api script so that conflicts can be managed better

NateWr opened this issue · comments

Right now the plugin injects the Google Maps API script after the page is loaded. This improves page load speed a little bit, but the cost is that it's very difficult to manage conflicts.

If another plugin enqueues the Google Maps api as well, this can cause conflicts, for example with Modern Tribe's Events Calendar plugin. So they need to be able to dequeue the API script without disabling the map view in our plugin.

This presents a bit of an issue around how the maps are loaded. We are passing an initialize callback to the API as a query var, so that our maps spin up as soon as the API is loaded. If we continue to use this technique, dequeuing the API call will also disable our maps.

On the other hand, if we don't use the callback technique, we'll need to implement some kind of listener that checks when the API is loaded. I'm not super happy about that. It just seems like a lot of hassle. It might be worth diving into the Google Maps API to see if they emit any kind of loaded event we can listen to.