Hi Ricardo! Many thanks for the help on this one! Thanks to all of
you! :)

> That's not something you should worry about unless dealing with
> thousands of non-existing elements. Looking for 100 inexistent IDs in
> a page takes less than 10ms - that time increases considerably for
> other selectors.

Oh, wow! ~10ms, good to know. I was not sure how many lookups was too
many...

Additionally, thanks for the warning... I will be sure to use more
ID's in my jQuery.

> But that doesn't mean it's the right way to code it. You should have
> each page run only the functions it needs, if they can't be fired by
> an event you can test the window.location property to identify the

Ah, interesting! Great tip. :)

> page, or use a function call in each page's head. In the end you're
> not going to only look for the element, your code will try to run all
> the subsequent operations on the non-existent element. For best

Definitely! More excellent advice.

> performance your code blocks should be called depending on your
> website/application's state, not blindly on every page load.

Thanks Ricardo!

Looks like I have a long day ahead of me optimizing my current JS
file! :D

As I am learning to write better jQuery, I want to be sure I do not
pick-up any bad habits.

This list has been a life saver. Thanks all!

Cheers,
Micky

Reply via email to