Forum Moderators: not2easy

Message Too Old, No Replies

CSS fails to load, sometimes

serious problem

         

Namaste

7:58 am on Oct 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We recently redesigned our site in CSS.

The problem is that at random, on slow connections, the CSS fails to load. The page ends up without a layout. Upon refresh the CSS loads.

I have seen this issue on Slashdot's website once.

What's the reason and what's the remedy? My CSS is not very heavy, on some pages it is 8k and on others it's 9k.

directrix

4:26 pm on Oct 1, 2005 (gmt 0)

10+ Year Member



I've occasionally seen this on my site, too, and my CSS is only about 1.2K!

The problem has been noted on Webmasterworld before; see for example here [webmasterworld.com] and here [webmasterworld.com].

It sounds like an IE bug. If you wanted to stop it happening on, say, your home page, you could place the CSS for that page directly in the header. In fact, you may be able to strip out most of the CSS, as you'd need only what is relevant for that page. So the home page may even end up loading faster! The downside would be a delay of an additional page before the external CSS file is cached.

Namaste

5:14 pm on Oct 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I find the problem is browser indepedent. It happens in Mozilla, FF & IE

dragonthoughts

11:02 am on Oct 3, 2005 (gmt 0)

10+ Year Member



If CSS isn't loading, sometimes, that suggests server, browser or connection problems.

Another thing to watch for is that your server is set to serve CSS files as text/CSS and not anything else.

It's worth trying to design your site, so it works reasonably well without CSS (For US government sites this is a requirement), but you could consider including the most vital parts of the CSS within a <style> delaration in the page content (not too much though) and then having a later line which actually includes your stylesheet.

This means that if you update your styles in the future, the linked one will take precendence without you having to change the pages, but if it fails to load you'll still have a prettier site than with no CSS.
This is based on the Cascade part of the "Cascading Style Sheets".