W3C home > Mailing lists > Public > public-web-perf@w3.org > July 2011

Re: Open Source Cross-Browser setImmediate in JavaScript

From: James Robinson <jamesr@google.com>
Date: Tue, 5 Jul 2011 22:37:22 -0700
Message-ID: <CAD73mdJyGeJhFG5DnWLV5Z1pPsFx1WEcKWznwi8MGSV0JVfjvA@mail.gmail.com>
To: Paul Bakaus <pbakaus@zynga.com>
Cc: Donavon West <dwest@book.com>, "public-web-perf@w3.org" <public-web-perf@w3.org>
Thanks both of you for the feedback.  Could you give some examples (ideally
with code) of when you would want to use setImmediate() and why existing
mechanisms (like setTimeout()) are not ideal?

- James

On Mon, Jul 4, 2011 at 8:13 AM, Paul Bakaus <pbakaus@zynga.com> wrote:

> Hi Donavon,
>
> I definitely like this, as process.nextTick seems very efficient. I'm
> wondering though if you could give an explanation of the actual difference
> between setTimeout and setImmediate. I, for instance, often use it to wait
> for reflows and repaints.
>
> Thanks,
> Paul
>
> Am 02.07.11 06:43 schrieb "Donavon West" unter <dwest@book.com>:
>
> >I wrote Jason Weber and he turned me on to this group. Our desktop
> >Mac/PC applications use Webkit to create a custom "harness" for our NOOK
> >Study higher education ereader (http://nookstudy.com). It looks and
> >feels like a native desktop app, but uses web based technologies under
> >the hood. As such, we have thousands of lines of rather intense
> >JavaScript/HTML5/CSS3 code. As a developer, I really appreciate a faster
> >setTimeout(0) alternative and advocate for getting setImmediate into
> >future browsers.
> >
> >I've written a cross-browser JavaScript implementation of setImmediate
> >along with a QUnit test suite (which could be used to test browser
> >implementations as well). It is open source and you can get it at
> >https://github.com/NobleJS/setImmediate (if you build on the tests,
> >please update GitHub).
> >
> >My thoughts on the setImmediate API:
> >
> >* personally I think that making it semantically identical to the
> >setTimeout API was overkill. A simple node.js process.nextTick would
> >suffice. I don't think anyone will ever call setImmediate and then clear
> >it. However,  for the sake of completeness it doesn't hurt to leave it
> >in (you can simply ignore the returned handle).
> >* please remove the case for a string eval'ed handler argument. Stop the
> >madness! Stop it now!
> >
> >Donavon West
> >Software Development Manager
> >Barnes and Noble.com
> >
> >
> >This electronic mail message contains information that (a) is or
> >may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE
> >PROTECTED
> >BY LAW FROM DISCLOSURE, and (b) is intended only for the use of
> >the addressee(s) named herein.  If you are not an intended
> >recipient, please contact the sender immediately and take the
> >steps necessary to delete the message completely from your
> >computer system.
> >
> >Not Intended as a Substitute for a Writing: Notwithstanding the
> >Uniform Electronic Transaction Act or any other law of similar
> >effect, absent an express statement to the contrary, this e-mail
> >message, its contents, and any attachments hereto are not
> >intended
> >to represent an offer or acceptance to enter into a contract and
> >are not otherwise intended to bind this sender,
> >barnesandnoble.com
> >llc, barnesandnoble.com inc. or any other person or entity.
>
>
>
Received on Wednesday, 6 July 2011 05:37:47 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:04:31 UTC