How to protect the site from API crashes?

Watching the consequences of today's disconnection of Google on the Internet, I thought about how to prevent this in the future. This might be a dumb question, but is there a good way to enable external APIs (like Google AJAX libraries) so that if the API is not available, the inclusive page can still remain without soldiers? Is it a bad idea to use libraries hosted on an external server in general?

+3
source share
7 answers

You cannot use a script tag to load cross-domain JavasScript files (this will result in a timeout if it drops). However, in your code, check that the API objects are null to avoid errors:

eg. instead:

<script type="text/javascript">
  google.load("maps", "2");
  // Use Maps API
</script>

:

<script type="text/javascript">
  if(google != null)
  {
    google.load("maps", "2");
    // Use Maps API
  }
  else
  {
    // Fallback
  }
</script>

, API.

+7

, ( ), , . Proxy Pattern ( ) , , , .

+3

, , . , , . , , . , , /API ..

- , . , API . .

API, , . ? . ? , , .

+2

, , ( $$). . JavaScript , api . , .

jQuery YUI . , .

+1

( , ):

cronjob, 10 // , . (), , , . , , .

, , , , .

, cronjob . , , .

+1

. , , - , .

100%, , , .

, , , , , , . , , , , , .

.

0

, Google - YUI, JQuery , .

0

Source: https://habr.com/ru/post/1708382/


All Articles