Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:43:30+00:00 2026-06-04T07:43:30+00:00

When loading a CSS/JS file from CDN or any external server, it is possible

  • 0

When loading a CSS/JS file from CDN or any external server, it is possible (even with low probability) to miss the file due to external failure. In this case, the html page will be corrupted in the lack of appropriate CSS and JS.

Is there a practical approach to load a local version upon CDN failure?

<link rel="stylesheet" href="http://cdn.com/style.css" type="text/css" />
IF (not loaded style.css){
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen" />
}

It would be easier to do this for JS, as we can test a JS function (provided in the JS file); then, loading the local file upon failure. For example, testing, if jQuery library is available.

However, I am curious to know if there is a practical method for this!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:43:32+00:00Added an answer on June 4, 2026 at 7:43 am

    I would do it this way.

    Create a class within your stylesheet ui-helper-hidden and then add a div as the first element on your page;

    <body><div class="ui-helper-hidden"></div><!-- rest of html --></body>
    

    After you have checked to make sure your CDN javascript file has been loaded, then use this bit of code note i am using jquery

    <script>
        // CSS Fallback
        $(function () {
            if ($('.ui-helper-hidden:first').is(':visible') === true) {
                $('<link rel="stylesheet" type="text/css" href="/pathtocss/nameofstylesheet.css" />').appendTo('head');
            }
        });
    </script>
    

    This will check to see if the element which should be hidden is or not. If it isnt hidden, then you know your css file has not loaded from the CDN.

    I use this method for jQuery and jQuery UI via a CDN

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am loading a HTML from an external server. The HTML markup has UTF-8
I've seen many examples of loading CSS and javascript dynamically from a file. Here's
I am having a problem loading a javascript or css or any other file
What is the best way to handle browser-specific CSS file loading? Assume you are
I have a html wrapper app loading all js, css and images from ipad
while loading getfptex(got it from CTAN) batch file ,when i'm extracting this batch file
I'm loading yui.js 3.3.0 version file from portlet but liferay its using 3.2.0 yui.js
I can't link external css file to html The HTML file is situated in
I need help on timing issues between CSS file and HTML code from AJAX.
My css file is not loading. I have just installed apache2 with php on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.