CDN Fallback for ArcGIS JSAPI

Document created by randybonds on Apr 20, 2016Last modified by randybonds on Apr 20, 2016
Version 2Show Document
  • View in full screen mode

Here's how I solved the problem of needing a fall back for when/if the CDN goes down.

  1. Download the JS from SDK Downloads | ArcGIS for Developers  and follow the setup instructions.
  2. For the sake of this tutorial, I have placed the 3.16 files at /js/3.16/ on my webserver
  3. Place these two lines of code in place of the normal js include
<script src="https://js.arcgis.com/3.16/"></script> 
<script> window.dojo || document.write('<script src="/js/3.16/init.js">\x3C/script>');</script>

It check to see if dojo has been loaded, which is essentially seeing if the js library has been loaded. If not, it loads the local version.

3 people found this helpful

Attachments

    Outcomes