googlemap plugin : how to load js only if needed?

vincent3569 Member, Translator
hi
if googlemap plugin is enabled, googlemap js scripts are loaded in all pages of zenphoto, even if functions of plugin are not used.
it causes a lot of delay when loading pages.

how to load googlemap js scripts only if functions (as printGoogleMap()) are used?

Comments

  • acrylian Administrator, Developer
    You would have to modify the the plugin completely. You could rework it so it works like Colorbox plugin or the slideshow plugins currently where you have to enable the script for specific pages.

    This is actually something we will eventually drop in the future though because it is bad usability and frequently turns out to cause confusion like "I have enabled the plugin but why it is not working".

    The "sideway" openstreetmap" plugin is much more slim regarding scripts loaded. Just to note… It's not googlemaps of course…
  • fretzl Administrator, Developer
    On pages where you do not use `printGoogleMap()` you can add

    `<?php zp_remove_filter('theme_head', 'GoogleMap::js'); ?>`

    before

    `<?php zp_apply_filter('theme_head'); ?>`
  • vincent3569 Member, Translator
    thanks for this workaround !

    no so easy to code, because I have a commom header file included in all my pages (gallery, albums, images, pages, news,...), but I will have a look !!
Sign In or Register to comment.