Forum Moderators: not2easy

Message Too Old, No Replies

Page Speed to embed or not

         

Hissingsid

9:38 pm on Nov 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've had a play with the websiteoptimization tools and removed some of the obvious inefficiencies on one of my sites. I'm now thinking about structural issues.

From an individual page speed point of view is it better to embed css in the HTML page or have it in an external file? The site uses PHP so I could include the css from a site-wide file.

Is the reduction in the number of http requests worth the loss of caching of an external style sheet from a site wide point of view?

I'd be interested to hear opinions and discuss ideas for improving efficient use of css code.

Cheers

Sid

swa66

9:44 pm on Nov 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If visitors come for more than one page, it should favor the cashing and let the external file win significantly.
The difference is a choice between an extra hit on the initial page vs. a hit in size on every single page.

Over time this balance might also change as your site grows (in number of pages and in CSS filesize)

Swanny007

10:07 pm on Nov 26, 2009 (gmt 0)

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



I've been wondering about this too. I just switched to putting the CSS in the head area directly because the average visitor doesn't view many pages, plus the CSS code it is now gzip'd since it's in the "main" files.

If you use gzip or compression and you don't have much CSS it may be better to put it in the head. If you don't use compression or have a lot of CSS, you'll probably want to leave the CSS in a separate file so it can be cached.

Swanny007

12:49 am on Nov 27, 2009 (gmt 0)

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



Oh, and congrats on 1,000 posts.

Hissingsid

11:44 am on Nov 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On my top $ site it is the home page that ranks for the most important keywords, so here's what I've decided to do.

On this and other high ranking pages and Adwords landing pages I intend to embed cleaned up css. For now other pages will continue with the existing but cleaned up and compressed external css file/s. If evidence comes to light that Google is looking at speed from a site perspective rather than a page perspective I may spend time polishing other pages.

Cheers

Sid

PS Thanks for the congrats! Most of my posts were in the immediate Florida aftermath when I seemed to spend 16 hours a day on the Google forums with the other 8 hours fitfully trying to get to sleep.