Live data from Hacker News

Faster than jQuery(document).ready() - Wait Until Exists

javascriptisawesome.blogspot.com

21–30 of 48 posts

Re: Faster than jQuery(document).ready() - Wait Until Exists

#21

Earlier quoted context omitted.

I'm all for bringing back vote counts, I do sorely miss them... but I have to ask, in this particular case, how would mankind be served if we knew that 127 more people agree with cstuder? Maybe I'm missing something, this is an honest question.

If people saw [ 528 ] as the vote count for that comment, they'd be less likely to upvote it themselves.

Huh? So what if people upvote a comment with many votes... no harm done, right?

Re: Faster than jQuery(document).ready() - Wait Until Exists

#22
post #13

Earlier quoted context omitted.

this is why we need vote counts to be displayed again.

I'm all for bringing back vote counts, I do sorely miss them... but I have to ask, in this particular case, how would mankind be served if we knew that 127 more people agree with cstuder? Maybe I'm missing something, this is an honest question.

Helps three groups of people.

1. Those who aren't familiar with the topic. With a single-digit score, there's potentially not much value there. With a three-digit score, hey, maybe people shouldn't use large images in the background. Then this person can either follow it or look up or ask why this is. It's marking significance to an otherwise unknown topic.

2. Similarly, if the author of the site sees this, they can see just how many people agree with this. This is important because again, high score means people agree with it. This person may still not take action, but should at least consider it if it's a high enough score. Maybe even chime in and respond with a rationale.

3. The rest of the community. This will either acknowledge your own views or raise a red flag if the score is high enough. Did you miss something? Are enough people just plain wrong according to what you believe to be true? Should you post a counter-point or add/ask for clarification?

Re: Faster than jQuery(document).ready() - Wait Until Exists

#23
post #20

Earlier quoted context omitted.

I'm all for bringing back vote counts, I do sorely miss them... but I have to ask, in this particular case, how would mankind be served if we knew that 127 more people agree with cstuder? Maybe I'm missing something, this is an honest question.

the problem is that without a vote count, how do you know if 2 people voted for it (and thus really isn't a big deal), or 127 (and thus, the OP should really fix his stupid site). The only alternative are "me too" posts, which are hideous (and which is basically what my reply was). In short, as-is, the OP really has no way of knowing just how aggravating his site is.

Thanks for explaining your comment, that makes sense. I do think, however, that your parent's comment makes a point on its own merit, not sure it needs to be "me too'd" 127 times to be heard. It also gets a prominent position on the page even without a vote count.

I'll concede that 127 visible upvotes are much preferable to 127 "me too" replies, though!

Re: Faster than jQuery(document).ready() - Wait Until Exists

#24
I like the idea and it does seem that it could reduce the time that your JavaScript code has to wait before it can run. However, in reality most real JavaScript front end code frameworks require not just one element but multiple elements, and nested elements. I would be hesitant to start running JavaScript just because one element was ready unless I was sure that other elements that my code referenced or manipulated were also ready. I'm sure it would be possible to make a version that allowed you to specify a list of elements to wait for before running code, but then that creates a nightmare for code maintenance, keeping track of the entire list of elements that your JavaScript requires. For me the jQuery(document).ready() method seems easier and more reliable.

Re: Faster than jQuery(document).ready() - Wait Until Exists

#25
post #14

Earlier quoted context omitted.

I think he meant faster as in executed before, rather than in executed faster.

Still doesn't answer the question: how much earlier is it executed? I would like to know.

actually, the script doesn't make any sense because it would be executed as soon as the browser is idling, that is after it has rendered the dom completely, that is when the DOMContentLoaded event fires. The right way to run a script right after an element has been created is to place the script right after the element closing tag.

You still can use it for setting late binding event handlers though.

Re: Faster than jQuery(document).ready() - Wait Until Exists

#27

Earlier quoted context omitted.

I'm all for bringing back vote counts, I do sorely miss them... but I have to ask, in this particular case, how would mankind be served if we knew that 127 more people agree with cstuder? Maybe I'm missing something, this is an honest question.

Helps three groups of people. 1. Those who aren't familiar with the topic. With a single-digit score, there's potentially not much value there. With a three-digit score, hey, maybe people shouldn't use large images in the background. Then this person can either follow it or look up or ask why this is. It's marking significance to an otherwise unknown topic. 2. Similarly, if the author of the site sees this, they can…

These are all good reasons to bring back vote counts (which, again, I'm in favor of) but only your point (2) is a reply to my question about this particular case. (1) and (3) would apply to any comment here on HN.

I guess what I didn't take into account in my previous comment is that the guy responsible for the animated GIF might drop by HN and might take the GGP's comment more seriously if he sees a large number of votes attached to it. This makes sense and is another good reason to get vote counts back here, especially if it discourages others from posting me-too comments.

Re: Faster than jQuery(document).ready() - Wait Until Exists

#28
Does someone have a really good example of where this would be useful? The description is basically, "When this element exists, do something" but what is the something you'd do? If it's styling, that should be done in CSS. If it's event handlers, that can be done with `.live()` or `.delegate()`.

I'd also like to see some benchmarks to back up the assertion that this is faster. The DOM modification events are generally accepted as slow and it seems like this is leaving a handler attached for the duration of the page's existence.

Re: Faster than jQuery(document).ready() - Wait Until Exists

#29

Earlier quoted context omitted.

I'm all for bringing back vote counts, I do sorely miss them... but I have to ask, in this particular case, how would mankind be served if we knew that 127 more people agree with cstuder? Maybe I'm missing something, this is an honest question.

If people saw [ 528 ] as the vote count for that comment, they'd be less likely to upvote it themselves.

That would be a bug, not a feature.

If you see a comment or article you approve of, you should upvote it, regardless of how popular (or not) it is among other people. If there are 529 people who approve of a certain comment, then it comes by those 529 upvotes honestly.

Re: Faster than jQuery(document).ready() - Wait Until Exists

#30

Does someone have a really good example of where this would be useful? The description is basically, "When this element exists, do something" but what is the something you'd do? If it's styling, that should be done in CSS. If it's event handlers, that can be done with `.live()` or `.delegate()`. I'd also like to see some benchmarks to back up the assertion that this is faster. The DOM modification events are generall…

some UI stuff could benefit from this: things like turning a list into an accordion. (Normally there is at least a little work to be done to ensure you don't get a flash of unstyled/unscripted content, if this fires fast enough you could avoid that)
Post reply on HN