Using CDN with Fallback on local server when loading Javascript and CSS of Kendo/JQuery/Modernizr

Thread is closed for posting
2 posts, 0 answers
  1. D5D618D3-CAB9-4157-A1BB-D33E871094B0
    D5D618D3-CAB9-4157-A1BB-D33E871094B0 avatar
    1 posts
    Member since:
    Jan 2014

    Posted 29 Jan 2014 Link to this post


    Telerik Product and Version

    Telerik Kendo UI Web, any version (Optional: Kendo UI Dataviz)
    Microsoft ASP.NET MVC 5
    Microsoft Visual Studio 2013

    Supported Browsers and Platforms


    Components/Widgets used (JS frameworks, etc.)

    Kendo UI, jQuery, Modernizr

    Using Cache Delivery Network (CDN) for loading Javascript and CSS files is great, but what if the CDN server fails?
    Answer: your application breaks down looking ugly...

    So the solution it to first try to load from a CDN, then load from the Local Server files if Javascript was not loaded correctly from the CDN (the fallback).

    This project shows how to load jQuery/Kendo/Modernizr from a Cache Delivery Network, and fallback to local server files if the CDN were unavailable.
    It even tries several CDN for jQuery and Kendo, prefering CDN which are compatible with https.

    All this implementation CDN-Fallback for resides in the Views/Shared/_Layout.cshtml file (in the html/head section)Happy coding!
  2. 2D95F235-B3CE-414A-BD6E-7B2E8B7CF5CD
    2D95F235-B3CE-414A-BD6E-7B2E8B7CF5CD avatar
    8486 posts
    Member since:
    Apr 2023

    Posted 21 Mar 2014 Link to this post

    Hi Michel,

    Thank you for the code library example. I think it has a couple of issues though:

    1. The modernizrVersion variable is not used correctly inside Url.Content(), which leads to an always invalid URL.

    2. If the Kendo UI scripts fail to load, then window.kendo will be undefined and window.kendo.jQuery will trigger a Javascript error. The conditional statement should only check whether window.kendo is defined (or just kendo).

    On a side note, we have updated our documentation to outline such scenarios:


    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.