Skip to main content

Bug Tracker

Side navigation

#10417 closed feature (fixed)

Opened October 04, 2011 03:39PM UTC

Closed December 11, 2012 01:58AM UTC

Last modified January 15, 2013 02:13AM UTC

Remove second arg from setTimeout calls (WAS jQuery.later)

Reported by: gnarf Owned by: gnarf
Priority: low Milestone: 1.9
Component: core Version: git
Keywords: 1.9-discuss Cc:
Blocked by: Blocking:
Description

We are starting to use more and more

 setTimeout( fn, 0 ); 
calls around our code base. I think now that there is also a
 setImmediate 
and there is also the postMessage that we should probably try to take advantage of these.

I would like to propose a

 jQuery.later( fn ) 
that wraps the "best" possible function here.

Attachments (0)
Change History (28)

Changed October 04, 2011 03:41PM UTC by gnarf comment:1

keywords: → 1.8-discuss

Changed October 04, 2011 03:42PM UTC by gnarf comment:2

description: We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.

Changed October 04, 2011 03:47PM UTC by rwaldron comment:3

neat!

Changed October 04, 2011 03:47PM UTC by rwaldron comment:4

component: unfiledcore

Changed October 07, 2011 12:32AM UTC by dmethvin comment:5

priority: undecidedlow
status: newopen

Changed December 01, 2011 01:37PM UTC by sindresorhus comment:6

#10936 is a duplicate of this ticket.

Changed December 13, 2011 02:59PM UTC by jzaefferer comment:7

description: We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these.\ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.

-1, There is no reason why this needs to depend on jQuery apart from bundling it.

Changed December 13, 2011 04:17PM UTC by jaubourg comment:8

+1, not only does it make sense, it should also save some size.

Changed December 13, 2011 06:20PM UTC by dmethvin comment:9

description: We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these.\ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.

+1, It's small and we can use it internally, so yeah.

Changed December 14, 2011 01:25AM UTC by mikesherov comment:10

description: We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these.\ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.

+1, mostly fluff, but honestly, I'm personally sick of setTimeout( fn, 0). Let's do it.

Changed December 14, 2011 04:34AM UTC by rwaldron comment:11

description: We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these.\ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.

+1, Seems highly useful

Changed December 14, 2011 04:07PM UTC by timmywil comment:12

description: We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these.\ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.

-1, I don't think it's worth it

Changed December 16, 2011 12:21AM UTC by hkdobrev@gmail.com comment:13

+1

It should save size and it would really prevent jQuery users from bad usage of setTimeout. For example many developers still do things like:

setTimeout("a lot of javascript in a string", ...)

Changed January 04, 2012 07:01AM UTC by gibson042 comment:14

I like the standardization and size neutrality (jquery.js has 5 instances of setTimeout( fn, 0..1 ), making this cost at most 12 bytes minified). But how about calling it jQuery.soon?

Changed January 09, 2012 05:36PM UTC by gnarf comment:15

description: We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these.\ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.We are starting to use more and more {{{ setTimeout( fn, 0 ); }}} calls around our code base. I think now that there is also a {{{ setImmediate }}} and there is also the postMessage that we should probably try to take advantage of these. \ \ I would like to propose a {{{ jQuery.later( fn ) }}} that wraps the "best" possible function here.
owner: → gnarf
status: openassigned

Changed January 09, 2012 08:35PM UTC by timmywil comment:16

I'll elaborate. I don't think this will give us the benefit we're looking for. In terms of performance, adding the function call will likely negate the benefit of using postMessage. The best performance always has the smallest stack. Besides, we're talking ops in the millions if comparing postMessage to setTimeout. As for setImmediate, it is not currently implemented in any browser except IE and will probably never become part of the spec. IE10 will implement it as msSetImmediate. I definitely don't think we should make use of that yet.

It is my understanding that the overall direction for browser vendors is to optimize for setTimeout(fn, 0) rather than add another function. We could very well be forcing the jQuery API to go in a direction we will regret later. I'm not saying never, but I suggest we table it.

Changed June 11, 2012 08:41PM UTC by gnarf comment:17

Even if it doesn't wrap any other method, just having it wrap setTimeout( fn , 0 ) is nice

Changed July 14, 2012 02:08AM UTC by dmethvin comment:18

We haven't done this yet in 1.8, but I'm also not seeing any place where it is going to save us anything in the current code. Thoughts? Should we push to 1.9 and discuss then?

Changed September 17, 2012 05:48PM UTC by gibson042 comment:19

keywords: 1.8-discuss1.9-discuss

Changed September 24, 2012 04:59PM UTC by dmethvin comment:20

Thoughts about the benefits? The setTimeout implementation adds a relatively large delay but is not a lot of code. I'm on the fence about it now.

Changed September 26, 2012 09:23PM UTC by gibson042 comment:21

I'm neutral on this too, but +1 if it reduces size.

Changed October 14, 2012 10:21PM UTC by mikesherov comment:22

+1, I'm with @gibson042 on this. If it's smaller, sure.

Changed October 14, 2012 11:18PM UTC by rwaldron comment:23

+1, But we need to bikeshed on the naming

Changed October 22, 2012 05:17PM UTC by gibson042 comment:24

+1, if it reduces size

Changed October 29, 2012 04:59PM UTC by anonymous comment:25

+1

Changed October 29, 2012 05:02PM UTC by mikesherov comment:26

milestone: None1.9

Changed December 11, 2012 01:58AM UTC by Oleg comment:27

resolution: → fixed
status: assignedclosed

Fix #10417. setTimeout w/o 2nd arg is jQuery.later! Close gh-1065.

Changeset: d41b983259042d3a07ae785c09f71c68d9ce7c3f

Changed January 15, 2013 02:13AM UTC by dmethvin comment:28

summary: jQuery.laterRemove second arg from setTimeout calls (WAS jQuery.later)