Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript and CSS Development with jQuery
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 25th, 2010, 11:52 AM
Registered User
 
Join Date: Jul 2007
Location: Olympia, WA, USA.
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?
Reply With Quote
  #2 (permalink)  
Old February 25th, 2010, 12:10 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
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?
Reply With Quote
  #3 (permalink)  
Old February 25th, 2010, 12:10 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.