Wrox Programmer Forums
|
BOOK: Beginning JavaScript and CSS Development with jQuery
This is the forum to discuss the Wrox book Beginning JavaScript and CSS Development with jQuery by Richard York; ISBN: 9780470227794
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript and CSS Development with jQuery section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2010, 11:52 AM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default using type selectors with id not efficient

On page 12, Mr. York recommends including a type selector with the id selector in CSS; for example, "div#thisID".

This practice is called inefficient by Mozilla; see https://developer.mozilla.org/en/Writing_Efficient_CSS.

So my question is, who is correct? Mr. York may want to fully qualify the CSS specification for easy recognition by programmers, but does this have a performance cost?
 
Old February 25th, 2010, 12:10 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

They are both correct.

Richard is talking about things from a stylistic and maintenance point of view. The Mozilla article is written from a performance stand-point.

If performance is the biggest criteria in your application then follow the Mozilla guidelines. If you want more readable and maintainable code that is easier to debug and work with and can afford whatever small performance hit it costs then follow the books guidelines.

After all, they are both just guidelines, not strict rules. I would recommend trying to pick one and stick with it though, just to be consistent.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old February 25th, 2010, 12:10 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

In all my years of programming I've never noticed any performance degradation.

I guess if you're making a really long page with thousands and thousands of elements, you'd see a performance cost. But if I were in that situation, I would be more concerned about why I needed so much content in one page than I would be about how I wrote my style sheet.

In the end, I prefer including the type selector, because I find it easier to read and easier to relate what's styling what, and I think that's more important than a minor milliseconds level performance cost. You are, of course, your own person, so do what's right for you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS3 Selectors m_norouzi CSS Cascading Style Sheets 1 November 4th, 2007 10:58 AM
how to parse xml with an attributes of type ID kirkpng XSLT 1 January 25th, 2005 04:44 PM
Record Selectors Teqlump Access 2 December 28th, 2004 09:56 AM
Data Type for table ID syu SQL Server 2000 3 February 26th, 2004 11:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.