Forum Moderators: not2easy

Message Too Old, No Replies

CSS files - how to load faster

         

wheel

3:23 pm on Mar 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've used a program to generate pages from one format to web format. The program uses one monster CSS file for all the pages. So I've got css files to the tune of 10-30megs. Yeah, I wish I was kidding.

Any thoughts on how to decrease the page load speed as a result of this problem? First page takes forever to load.

Swanny007

3:34 pm on Mar 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A few things that come to mind....
-gzip it, send it compressed
-Run it through one of those online CSS optimizer scripts
-Manually go through and remove unnecessary code
-Serve the CSS file through a CDN like MaxCDN so it's closer to end users
-Or use a new layout ;-)

g1smd

3:39 pm on Mar 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is that one of those "systems" that gives every content paragraph a new ID then writes a block of CSS to style that paragraph? You end up with the same CSS definition repeated several thousand times but with a different ID for each one. I'd like to find the idiot that writes such junk and give him or her a piece of my mind. Using a class would have reduced the CSS to a few hundred lines.

wheel

3:50 pm on Mar 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, it's an automated process. hard to clean up manually.

- I've called my host and asked them to gzip css files.
- I tried an online css optimizer. It broke :).
- I looked at CDN's, there's only one in my country and it's not affordable for this site. However, the site is not on my main server, it's on a local hosting company. I suppose I could put the css files on my main server that is on huge pipes in this country and then reference them by IP address. That's probably 99% as good as a cloud anyway since my main host is already peer sharing with all the big ISP's in this country. It's some work, may be worth it if the site grows.

I think my best bet right now is to get the output gzipped. Estimates using an online tool showed it'll save about 92% since it's all text.

I appreciate the ideas, and welcome any others.

Swanny007

4:08 pm on Mar 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For the long term, you need to reduce the size of that file, big time.

BillyS

4:31 pm on Mar 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I've got css files to the tune of 10-30megs.


Do you get any visitors to that site? Even with a fast connection, it's going to take several seconds to load a page. Personally, I wouldn't wait that long for a page to load - I'd think the site is broken.

My advice... find another system.

wheel

4:40 pm on Mar 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using another system isn't an option right now. The content is generated and I can't restart - the effort outweighs the benefit. Yes, the first page loads slow. Subsequent pages are fast because the css file is cached.

Looks like the style sheet has a bunch of duplicate stuff, like
style-type1 {stuff}
style-type1 {more stuff}
style=type2 {stuff}
style-type2 {more stuff}

then individual pages reference some combination of those style-types.

I think compressing the output is the start. After that I may move it to my main server, to help increase speed. After that I think I'm going to have to bust the css sheet into 50 or 100 different sheets, one for each style-type. THen I can run a program through each page to remove the reference to the master css sheet, and replace it with references to just the style sheet references that are included in that page.

Was hoping for an easy answer :).