Faster than jQuery(document).ready() - Wait Until Exists
javascriptisawesome.blogspot.com
javascriptisawesome.blogspot.com
http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeI...
They have been deprecated because they perform poorly:
> Firefox, for example, when it realizes that a mutation event has been turned on, instantly goes into an incredibly-slow code path where it has to fire events at every single DOM modification. This means that doing something like .innerHTML = "foo" where it wipes out 1000 elements would fire, at least 1000 + 1 events (1000 removal events, 1 addition event).
http://lists.w3.org/Archives/Public/www-dom/2009AprJun/0072....
> Mutation Events are widely acknowledged as “slow” in terms of the real performance degradation that occurs on websites that use them heavily for tracking changes to the DOM
Don't use 1.49mb large GIF animations as background images...
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.
Everyone thinks they're just giving them a little bit. But all those little bits add up to a lot. Without any visibility into how much other people have already given them, there is no way for people decide if they really need the money or not.
If you saw a beggar on the street, and knew that they'd already been given $1000 so far that day, would you still give them a dollar?
In short, as-is, the OP really has no way of knowing just how aggravating his site is.
I'll concede that 127 visible upvotes are much preferable to 127 "me too" replies, though!
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?
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.
co;dr = cpu overheated; didn't read
You say it’s faster, but fail to provide any numbers / a jsPerf test case. I’m sure it’s faster to execute `waituntilexists()` initially, but if you take into account it uses an 5ms interval in which it traverses the DOM for the same elements over and over again until they’re finally found, it seems it probably has a negative impact on performance overall.
What’s wrong with event delegation anyway?
It uses getElementById to traverse the DOM and it is said to be the faster selector in javascript.
But your code should be faster -because you are polling at the 5ms interval!
You still can use it for setting late binding event handlers though.
* I could test it myself, but I expected to have in the article detailed information on the different possible states the document can have when my callback is called. The questions I know the answer when waiting for the whole document to be loaded : Is it half loaded ? What is the DOM state ? Is completely loaded ? If not, have the document JavaScript code been entirely ran ? and so on. This kind of question left unanswered often lead to hard bites.
* why using "itself" ? I would have used a "sensible default" : when no context is given, use the waited DOM object instead of an arbitrary value (document), and use something else when it is explicitly given. The "itself" thing should be left as an internal flag IMHO.
2) When i am writing javascript is very common for me to use the global object (window) as the context; so in my case is not a good idea to use the HTML element as context by default.
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.
I used this a lot when developing a Chrome extension for Facebook because i can identify when an HTML element is created via ajax.
You can do $(document).ready(), why not, the admittedly syntax sugared, $("div#main").ready().
I'd like to know if there is any performance hit though, NodeInserted fires on basically on every single fraction of page creation.
/Cufon.DOM.ready(function() {/ /$(window).load(function () {/ /$(document).ready(function() {/ /Cufon.DOM.ready(function() {/
And now is 40% faster