Hi @ppwebox,
Each Map plugin has its differences and may therefore require a separate integration. Aside of googlemap.js, there are a number of other MEC scripts that you would have to block (and some dependencies are necessary as well). That’s likely why the integration you created doesn’t behave as expected.
The integration that I mentioned in that year old thread is still there, the URL had changed though; due to the GitHub folder structure being updated.
https://raw.githubusercontent.com/Really-Simple-Plugins/complianz-integrations/master/Google%20Maps/webnus-modern-events-calendar.php
You can place it as a .php file in the /wp-content/mu-plugins/ folder.
Kind regards, Jarno
Thanks Jarno, this script works perfectly with Webnus MEC as far as I can see.
Hi @ppwebox,
Appreciate the quick confirmation, glad to hear that it works well for you!
If you’re happy with the plugin and our support, it would be really great if you could consider casting a review about the plugin here: https://wordpress.org/support/plugin/complianz-gdpr/reviews/
Kind regards, Jarno
Hi Jarno
While analyzing a client site (with Modern Events Calendar installed) for page load improvement I noticed that your script is loading Google Maps on every page which is bad for performance!
Would it be possible to modify the script to only load Google Maps on shop pages where the URL slug contains “/events/”? I tried the check in the cmplz_known_script_tags filter but Maps is still loading.
function cmplz_webnus_modern_events_googlemaps_script( $tags ) {
$tags[] = array(
‘name’ => ‘google-maps’,
‘placeholder’ => ‘google-maps’,
‘category’ => ‘statistics’,
‘urls’ => array(
‘richmarker’,
‘maps.googleapis.com/maps/api/js’,
‘googlemap.js’,
‘function mec_init_gmap’,
‘mecGoogleMaps’,
),
‘enable_placeholder’ => ‘1’,
‘placeholder_class’ => ‘mec-googlemap-details’,
‘enable_dependency’ => ‘1’,
‘dependency’ => [
//’wait-for-this-script’ => ‘script-that-should-wait’
‘maps.googleapis.com/maps/api/js’ => ‘googlemap.js’,
‘googlemap.js’ => ‘richmarker’,
‘richmarker’ => ‘function mec_init_gmap’,
‘richmarker’ => ‘mecGoogleMaps’,
],
);
return $tags;
}
add_filter( ‘cmplz_known_script_tags’, ‘cmplz_webnus_modern_events_googlemaps_script’ );
- Add services to the list of detected items, so it will get set as default, and will be added to the notice about it
- @param $services
- @return array
*/
function cmplz_webnus_detected_services( $services ) {
global $wp;
$url_slug = add_query_arg( array(), $wp->request );
$url_slug = ‘/’ . $url_slug;
if ( strpos($url_slug, ‘/events/’) !== false && ! in_array( ‘google-maps’, $services ) ) {
$services[] = ‘google-maps’;
} return $services;
}
add_filter( ‘cmplz_detected_services’, ‘cmplz_webnus_detected_services’ );
Hi @ppwebox,
The above snippet doesn’t enqueue the Google Maps scripts on its’ own, it blocks the ones that are loaded by the MEC plugin.
Kind regards, Jarno
Thanks for the clarification. But why omit that it is Complianz that is actually loading Google Maps on ever page (this site only really uses it on one singe page)?
Proof is in the html source code of every page:
<script type="text/plain" data-service="google-maps" data-category="statistics" data-cmplz-src="//maps.googleapis.com/maps/api/js?libraries=places&key=AIzaSyAI2EabN_2uN0AzVPflalJuBuJ6Yn8aAyE&language=de&region=DE&ver=7.4.0.1703811086" id="googlemap-js"></script>
So again: how can this senseless GMaps loading be circumvented and only load when it is actually called by the Modern Events Calendar plugin on the specific page? Complianz is seriously affecting page speed performance here!
Hi @ppwebox,
As mentioned, Complianz does not enqueue this script on the page. It merely modifies (blocks) the above script, which is enqueued by MEC itself.
You can check it yourself, disable Complianz for a brief moment and check the page again. You should find that the same script is still there, just without the Complianz consent parameters included now that it’s no longer active & blocking the script.
Kind regards, Jarno
Thanks Jarno, this is the case, indeed. Once again, the culprit is Modern Events Calendar.