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. Michel
    Michel avatar
    1 posts
    Member since:
    Jan 2014

    Posted 29 Jan 2014 Link to this post

    Requirements

    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

    All
               

    Components/Widgets used (JS frameworks, etc.)

    Kendo UI, jQuery, Modernizr

    PROJECT DESCRIPTION 
    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. Dimo
    Admin
    Dimo avatar
    8333 posts

    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:

    http://docs.telerik.com/kendo-ui/getting-started/javascript-dependencies#cdn-fallback-and-troubleshooting

    Regards,
    Dimo
    Telerik
     

    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