Problems from js file
-
Dear all, trying to fix some problems of WPGMaps plugin moderator highlight that some problems come from Google Language Translator. Herewith find all the analysis :
Hi Maurizio
I appreciate what you are saying completely, and I’m very sorry for any inconvenience caused, genuinely, I’m very sorry to be the bearer of bad news but I can categorically state that a JavaScript error in their code is causing the map to break.
Please allow me to explain how the flow of execution works on a page load.
Firstly, script tags are loaded and parsed, in the order they appear in the document.
Any code in these script tags is executed immediately after the script has been loaded and parsed.
Sometimes, it’s desirable to wait for all scripts to load before executing code, rather than executing immediately. This can be achieved by listening for the “document ready” event, which is usually done using jQuery.
These listeners are bound immediately, when the script loads.
Once all the scripts have loaded, jQuery fires the “ready” event, and each listener that bound to this event is called, in the order that they were bound in.
If one of these listeners causes an error, execution will halt. When execution halts, no further listeners will be called.
So, if plugin A binds a ready listener, then plugin B binds a ready listener, when the ready event fires, if plugin A’s listener causes a JavaScript error, then the ready event will not fire for plugin B.
When I look at my console on your site, I can see this error:
Uncaught TypeError: $(…).toolbar is not a function
at HTMLDocument.<anonymous> (scripts.js:59)
at i (jquery.js:2)
at Object.add [as done] (jquery.js:2)
at a.fn.init.n.fn.ready (jquery.js:2)
at scripts.js:58
From this line:
at a.fn.init.n.fn.ready (jquery.js:2)
We can see that this is during the jQuery ready event.
From the top of the stack trace, you can see that the file scripts.js is causing this error on line 59.
If you look at the full URL for scripts.js, you will see that is https://www.ferentino.org/wp-content/plugins/google-language-translator/js/scripts.js
See google-language-translator in that path for the name of the plugin causing this error.
This error is triggered by the Google Language Translator plugin trying to call a function named toolbar when no such function exists. When an error happens, execution halts, and the ready event will not be triggered for any JavaScript listeners that were bound after Google Language Translator loaded and bound this listener.
Please see my first attachment showing the stack trace for this error.
Please see my second attachment showing the file https://www.ferentino.org/wp-content/plugins/google-language-translator/js/scripts.js, where this error originates from.
I can use the live source edit and source overrides to remove this in my development environment, without modifying the file on the server. Please see my third attachment for the overriden file, in which I have commented (effectively removed) the code causing this error.
If I do that, then reload the page, that code is not run, so the ready event is not interrupted, the flow of execution continues, the ready event listener fires for our plugin code, and the map is displayed and fully functional, as you can see in my fourth attachment.
I’m very sorry for any inconvenience caused, I appreciate that this can seem befuddling, we do put out at lot of updates as we are constantly working to improve the product and it’s compatibility with other plugins. I really don’t wish to pass the buck so to speak, but I’m afraid that I can state without any doubt whatsoever that is caused by the Google Language Translator plugin trying to call toolbar when no such function exists. We would be unable to advise you on a fix for this as this pertains to their code.
I can advise you that removing this code will solve the problem, as you can see above, however as I’m not familiar with their code, I can’t advise you on what the deeper consequences of removing that code might be. You would need to ask the plugin author about this, firstly I would ask them why their code is failing here, and secondly if they’re unable to advise on a fix, I would ask if it’s safe to remove this code.
I would also advise that this error will stop the ready event from firing for all plugins that subsequently bound the listener, not just WP Google Maps, so in any case, I would advise that you take this up with them to get this solved as this will likely cause problems with other plugins too.
I really hope that makes sense. We do strive to be as compatible as possible with other plugins, of which there is a myriad of combinations and configurations, but I’m afraid that in this instance because their code stops our from executing at all, you would either need to remove that or speak to them. We would be quite happy to facilitate that if it would help.
I hope that makes sense and is of some help?
Kind regards
– Perry
Attachments:2019-01-16-08_09_19-DevTools-www.ferentino.org_ferentinesi-nel-mondo_.png
2019-01-16-08_10_09-DevTools-www.ferentino.org_ferentinesi-nel-mondo_.png
2019-01-16-08_11_20-DevTools-www.ferentino.org_ferentinesi-nel-mondo_.png
2019-01-16-08_12_15-Ferentinesi-nel-mondo-ferentino.org_.png
all above said is available at this link:
AnalysisThe page I need help with: [log in to see the link]
- The topic ‘Problems from js file’ is closed to new replies.