CDN Fallback for ArcGIS JSAPI

3958
2
04-20-2016 10:50 AM

CDN Fallback for ArcGIS JSAPI

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.

Comments

Good idea, I have this as a parameter in the app I can change through a db script, but that requires identifying the problem and applying a fix after the fact. This is a more robust way to do this seamlessly. But, I mean the CDN ​never goes down, right? Right?!

Ha ha, yeah never

Version history
Last update:
‎12-12-2021 09:04 AM
Updated by: