3

I'm 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 include it wherever I need it:

define(['googleMap'], function () { ... });

From China for example, Google Maps is forbidden and it will result with a "Load timeout for modules: async!googleMap". This will also break the entire website as the dependency is not available.

How can I catch that error so the app can run? Then wherever I use googleMap I would check that the object 'google' exists before using it.

Vincent Peres
  • 894
  • 11
  • 26
  • possible duplicate of [How to handle requireJs timeout error?](http://stackoverflow.com/questions/18332748/how-to-handle-requirejs-timeout-error) – Louis May 07 '15 at 16:21

1 Answers1

0

I think you can ping the site before you pull your js, just like this answer does:

Is it possible to ping a server from Javascript?

Community
  • 1
  • 1
kaho
  • 4,650
  • 1
  • 13
  • 24