Discuss: Keeping Your Elements’ Kids in Line with Offspring
by Alex Bischoff
- Editorial Comments
2 jQuery as another option?
Could many of the concepts discussed be implemented using jQuery as well?
posted at 09:02 am on February 5, 2008 by Jacob Boomgaarden
3 Typo in the article's code
There’s a missing closing <code> tag immediately above the heading “All together now”, which makes the last half of the article pretty hard to read.
In a more legitimate comment, I’d also be interested to see Offspring ported to something like jQuery or (my personal preference) Mootools.
posted at 09:43 am on February 5, 2008 by Ian Beck
4 Re: Measuring Page Rendering Time / Re: jQuery as
@thirukumaran: To measure the time taken, I created a one-off version of the code in which I checked the Date() object before and after processing the page; by subtracting one from the other, I had the elapsed time. (I then made use of OpenOffice Calc to help keep track of all the numbers and calculate the median values.)
@Jacob: Yeah, it may be possible to implement some of the functionality with other JavaScript libraries (such as jQuery). All the same, a more specialized library such as this one may be able to offer a lighter set of code than a general-purpose JavaScript library. (And, as it’s tuned toward a specific task, this approach may offer performance advantages as well.)
(Just to be sure, I have nothing against jQuery or other JavaScript libraries—they can be quite handy for any number of tasks.)
posted at 09:51 am on February 5, 2008 by Alex Bischoff
5 On Safari and do-it-all libraries, respectively
Fantastic work. Well done. Just one note — it is my understanding and experience that Safari does not implement last-child.
@ Jacob Boomgaarden : Yes, jQuery could certainly do this. However, many developers don’t want and many projects don’t need the overhead of that type of library. Offspring seems to be about doing one thing and doing it well.
posted at 10:00 am on February 5, 2008 by Ben Spaulding
6 Another one on Safari
Ben is right about Safari not supporting the last-child selector.
posted at 10:15 am on February 5, 2008 by Kari Pätilä
7 Re: On Safari
@“Ben Spaulding”:http://www.alistapart.com/comments/keepelementskidsinlinewithoffspring?page=1#5 : Good catch. Indeed, Safari hasn’t implemented support for last-child.
posted at 10:17 am on February 5, 2008 by Alex Bischoff
8 Using jQuery
On mid-to-large projects, where using a complete library is needed, such a script would be useless.
And using jQuery for example, would yield much more flexible results, as its CSS selectors are very complete.
I am, by no means, trying to flame here, but i really don’t see the point of a js library that does trivial things.
Wouldn’t it be better to simply use pure js to accomplish this?
I mean, if you only need the first-child of the navigation, its much faster to do:
var nav-items = document.getElementById(‘nav’).getElementsByTagName(‘li’);
nav-items0.class = ‘first-child’;
posted at 12:26 pm on February 5, 2008 by Andrei Eftimie
9 Untitled
Might be worth having another look at Dean Edwards’ ie7 (and now ie8) script. He’s done some re-writing, and I believe it performs a bit better now.
Of course, Offspring and ie7/8 solve different problems, albeit with some overlap.
posted at 12:56 pm on February 5, 2008 by Paul Waite
10 Untitled
Unfortunately Opera also does not support the CSS 3 selector :last-child so it only works in Mozilla based browers.
posted at 01:24 pm on February 5, 2008 by Fonts K
Got something to say?
Discuss this article. We reserve the right to delete flames, trolls, and wood nymphs.
Create a new account or sign in below if you’d like to leave a comment.
Subscribe to this article's comments: RSS (what’s this?)




1 measure page rendering time
my i know what u used to mesure the time taken?
posted at 08:07 am on February 5, 2008 by thirukumaran kubendran