raring-coffee20
raring-coffee20

Reputation: 300

HTML: local web css refer to internet link?

I'm reading sourcecode of html files that has something like:

link rel='stylesheet' type="text/css" href="https://<internet-link.../abc.css" />

This website is completely local - run without internet, does this mean some part of this file would not run as expected because its style need to fetch from internet?

Upvotes: 0

Views: 615

Answers (1)

Bogdan Manea
Bogdan Manea

Reputation: 36

Yes, without internet no style will be applied. To fix this, you can initially include your online CSS file link and also use a local fallback. If the online file is not found or there is no internet connection, it will include the local one. For example:

<script>
(function($) {
    $(function() {
        if ($('body').css('color') !== '#000') {
            $('head').prepend('<link rel="stylesheet" href="/css/abc.css">');
        }
    });
})(window.jQuery);</script>

This checks if CSS from your online file was applied to your page and if not, it loads the local CSS file.

Upvotes: 2

Related Questions