How to catch loading error with RequireJS when Google Maps is down?
I am currently using the Async plugin to load Google Maps in our application using RequireJS ( https://github.com/millermedeiros/requirejs-plugins ):
define("googleMap", ['async!https://maps.googlee.com/maps/api/js?v=3&sensor=false']);
Then turn it on where I need it:
define(['googleMap'], function () { ... });
From China, for example, Google Maps is banned and this will result in "Load timeout for modules: async! GoogleMap" . It will also destroy the entire site as the dependency is not available.
How can I catch this error so that the application can run? Then, wherever I use googleMap, I would check if the google object exists before using it.
+3
source to share