D
D
Denis Ineshin2012-02-24 12:21:03
JavaScript
Denis Ineshin, 2012-02-24 12:21:03

javascript dynamic connection

Please tell me if it is possible to do something like this:

You need to connect a remote script, for example

<script  type="text/javascript" src="//remotehost1.com/script.js"></script>


At the same time, you need to check whether this script is available (preferably with a custom timeout) and if it is not available (for example, that server has crashed), connect another one, for example:
<script  type="text/javascript" src="//remotehost2.com/script.js"></script>

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mikhail Krainov, 2012-02-24
@IonDen

yepnope.js to help you

N
nill, 2012-02-24
@nill

The guys from Zeptolab have written a nice resource loader, this is probably what you need thinkpixellab.com/pxloader/

A
avalak, 2012-02-24
@avalak

There is also a variant from html5 boilerplate .

  <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>

A
Anatoly, 2012-02-24
@taliban

Look at the onload and onerror events of the script, although they write that there are no such events according to the standards, but browsers support them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question