Skip Navigation

[Résolu] Only load Toolset Maps scripts when needed

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Can we exclude Toolset Maps JS and CSS Scripts on our websites, so to load it only on pages where Toolset Maps is actually needed?

Solution:
No.
We have filed this request, and it has been discarded for now.

W keep upvoting requests as eventually in future we still can revisit them if the votes reach a considerable amount or else happens.

0% of people find this useful.

This support ticket is created Il y a 6 années et 9 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Ce sujet contient 8 réponses, a 3 voix.

Dernière mise à jour par Beda Il y a 6 années et 9 mois.

Assisté par: Beda.

Auteur
Publications
#615715

Hi,

I have another plugin that uses google maps.
My problem is that they are both enqueueing the google maps script, causing conflicts.

Is there a way to tell Toolset: "don't enqueue google maps scripts but they are already there" or "only enqueue them on pages that have a map in them?"

I have also contacted the other plugin developer and we are looking into a solution for the other plugin.
Thank you

#615833

There's not a setting that will prevent Toolset Maps from enqueueing Google Maps scripts. What is the other plugin?

#615857

The other plugin does not have that setting either. So both plugins are enqueueing the same script, unaware of the fact that there is already another plugin already using the maps script.
It's the same API key with the same APIs enabled, but I think this is a design oversight on both plugins.

Is there a way to request this fix in a future update?

#616037

Okay I can see how this is a problem when multiple plugins enqueue the same maps scripts. I will ask Beda, who handles feature requests for Maps, to consider this request and follow up with you.

#616055

We are aware of this and cannot provide a fix right now.

The issue here is that the scripts get loaded by different handles, even being the same scripts.
We register google-maps and the theme/plugin that might as well load it, but probably with different handle.

Would it be the same handle, it would just be loaded once.

So, this is a conflict we cannot solve right now, the solution would be not to use one of both softwares that provide or require maps API.

For reference:
https://toolset.com/errata/issue-when-using-the-toolset-maps-plugin-with-some-themes-and-plugins/

#616116

Toolset should be able to check when its shortcodes are loaded, and more specifically when the map shortcode is loaded, and only output the map scripts then. You can also include an optional checkbox which would load google maps globally. option #3: You can disable toolset's maps scripts on all pages by default and have a checkbox on each view/content template page saying [ ] load google maps script (but I think the first one is the most elegant and user friendly). Slider Revolution by themepunch does that with its scripts

#616295

Thank you.

I saw as well that Amit replied to your comment in the erratum.

The problem is, this has already been discarded a longer time ago, for valid technical reasons.

You should never use two different Maps solution on your site.

There is no simple way of "playing nice" without a sandard script handle, which does not exist for Google Maps API.

You should use one map solution and apply it everywhere you need a map.

Our Toolset Maps plugin does let you add custom maps to everywhere, providing an address or a pair of latitude/longitude coordinates.
I understand that after spending time and effort using another solution for specific things, switching is complex - or eventually you just want both because of certain features.

But it is your decision to make on which one to use.
Again, we do not recommend using two Google Maps providers on a single site.

In case a theme provides maps functionality, one should be careful when using another maps provider (Like Toolset Maps)

If one feels that the map provided by the external source (Toolset Maps) is better than the one included in the theme, the theme creators could help to disable it (Theme Maps scripts) completely.
Just dequeuing might not be enough since it could produce unexpected results caused by dependencies.

This is like using AntiVirus Software:
You can not (or should not) have two antivirus on a Windows machine, you can not load two versions of the same script without errors.
This is basically the same.

Usually, you apply a plugin for functionality (Toolset Maps) and a theme styles the things.
If the theme already provides this functionality you do not need Toolset Maps, or opposite, it might not be needed to use this Theme, or, the Theme should not provide functionality but style.

We can not detect whether a theme does contain a map implementation, mainly because the ones that do it right only register and enqueue it in the frontend, and with their own scrip handle (which results in the conflicts), and in the footer if possible.
So even if we can build a list of script names, we can only detect whether they exist and might cause a conflict on the frontend footer, but not fix it.

We can build a list of themes and plugins that are known to case conflicts and display that data somewhere in the backend, even check against a known function from the problematic items, but that list will never be comprehensive and checking against a long list can make wherever we show the warning a slow page (and basically, also not a very useful page anyway)

Unfortunately we do not see a solution for this.

#618026
Global_Settings.png

Sorry, but the "You should use one map solution and apply it everywhere you need a map." is not a real solutions.
I am using a Real Estate plugin that syncs data with the Canadian Real Estate Association on a daily basis. That plugin uses google maps to plot its own maps.

I agree, it would be stupid to include a view that uses google maps on the same page I am plotting real estate listings on.

What my issue is, is that WP-Views spits out that google maps script on every page, even the ones where I am not sure why I would even need to have the map scripts enqueued.

I don't think it is unreasonable to have a feature to disable map scripts from being enqueued, unless the page/post contains a shortcode which makes use of the map view.

I agree it's not an easy fix, but it is not impossible and I am sure it is a feature the entire community will come to appreciate WP-Views for.

Now I am talking about websites more complex than displaying a list of cars or houses with a few fields. I am talking about very complex databases, daily syncing with geocoding using cron scripts.

A lot of plugin developers seem to forget that their plugins don't run in a "perfect install" where only their plugin is installed on the twenty seventeen theme and that's it. There are thousands and thousands of WP plugins out there, and WP-Views is a pretty solid one. I use it as part of some stacks that push the limits of what is possible and it is incredibly robust and flexible, which is why I am so active on this community and why I love using it. Please don't be part of that group. We don't want to choose between a website looking great and having great functionality.

This maps issue is currently a handicap, preventing WP-Types and WP-Views from reaching its true potential on a lot of installation, just because if you have maps enabled, and you want to display a simple contact map, which maybe divi or wp-bakery page builder can whip up in 2 seconds, you have to go create custom views and apply dirty workarounds, when the plugin could just be courteous enough to allow for some exceptions.

Again I make reference to a plugin that does exactly this: Slider Revolution.

My screenshot shows the option.

You can use literally the same option on the maps tab in the settings, which would clear up any kind of issues you'd have. You can even leave it to on by default, but at least we have an option to make this plugin play nice. It's very possible and it has been done before.

#618259

I have filed this request, and it has been discarded.

I keep upvoting requests as eventually un future we still can revisit them.

For now, my hands are bound to passing along your concerns to the Developers and upvote the request.

I apologise that I cannot be of greater help in this case.