From e1c94888e4c7c8db5814e6c0d24a5ddd63947dad Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 5 Nov 2013 10:21:37 -0500 Subject: [PATCH] If the YouTube API JS fails to load, the rest of the JS should still run Fixes BLD-472 --- cms/templates/base.html | 13 +++++++++---- common/static/js/src/youtube_fallback.js | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 common/static/js/src/youtube_fallback.js diff --git a/cms/templates/base.html b/cms/templates/base.html index 0689cefab4..031006f818 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -80,10 +80,15 @@ // externally hosted files "tender": "//edxedge.tenderapp.com/tender_widget", "mathjax": "//edx-static.s3.amazonaws.com/mathjax-MathJax-727332c/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured", - // youtube URL does not end in ".js". We add "?noext" to the path so - // that require.js adds the ".js" to the query component of the URL, - // and leaves the path component intact. - "youtube": "//www.youtube.com/player_api?noext" + "youtube": [ + // youtube URL does not end in ".js". We add "?noext" to the path so + // that require.js adds the ".js" to the query component of the URL, + // and leaves the path component intact. + "//www.youtube.com/player_api?noext", + // if youtube fails to load, fallback on a local file + // so that require doesn't fall over + "js/src/youtube_fallback" + ] }, shim: { "gettext": { diff --git a/common/static/js/src/youtube_fallback.js b/common/static/js/src/youtube_fallback.js new file mode 100644 index 0000000000..23cdb12ddf --- /dev/null +++ b/common/static/js/src/youtube_fallback.js @@ -0,0 +1 @@ +console.error("Can't load YouTube -- anything that relies on it will fail");