Skip to main content

Bug Tracker

Side navigation

#7320 closed enhancement (wontfix)

Opened October 26, 2010 03:19PM UTC

Closed October 26, 2010 08:13PM UTC

Last modified February 23, 2011 10:36AM UTC

jQuery.now enhancement

Reported by: musicisair Owned by:
Priority: low Milestone: 1.5
Component: core Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:
Description

Date.now is faster than (new Date()).getTime() in supporting browsers.

See jsPerf benchmarks:

http://jsperf.com/date-now-vs-date-gettime

and

http://jsperf.com/new-date-value/3

Enhancement:

    now: Date.now || function() {
        return (new Date()).getTime();
    };
Attachments (0)
Change History (6)

Changed October 26, 2010 03:26PM UTC by anonymous comment:1

p.s. the "Preview" button on this bug tracker is completely useless since the styling rules are different from the tracker's actual styles. The "preview" honors the common "four-spaces-for-code-block" markdown style. The bug tracker then F's it all up. Where is the bug tracker for the bug tracker?

Changed October 26, 2010 08:13PM UTC by snover comment:2

keywords: → needsreview
resolution: → wontfix
status: newclosed

Seeing as how new Date().getTime() can be called at least 3 million times per second in every browser that supports Date.now(), I don’t see any reason to bloat the codebase with this. Someone else can reopen this ticket later if they strongly disagree.

Also, the styling rules for the preview are identical to the styling rules for the rest of Trac. Please read the WikiFormatting page. Prefixing space indicates blockquoting, not preformatted text.

Changed October 27, 2010 02:44PM UTC by musicisair comment:3

Hey, just want to present my argument here...then I'll leave it at that. :-)

IE9, Opera, Safari, Chrome, and FF support Date.now. Since jQuery.now is used in every animation step it couldn't hurt to speed it up by adding these 12 additional characters to the code base (Date.now || ).

Sorry for my outburst yesterday...I was tired, hungry, and stumped on a project of mine. Anyway, I can guarantee the styling is different from preview to publish...at least in the case of block quotes in Chrome 8.0.552.18 dev.

Changed November 02, 2010 02:13AM UTC by dmethvin comment:4

keywords: needsreview

Changed November 21, 2010 10:43PM UTC by snover comment:5

IE6/7 will keel over and die long before any performance benefit of Date.now could be realized in any of the browsers that support it, and every seemingly insignificant feature that gets added to core makes it bigger; cumulatively, enhancements like this are a contributor to a core library size that has doubled since version 1.2.

Changed February 23, 2011 10:36AM UTC by jitter comment:6

component: unfiledcore
description: Date.now is faster than (new Date()).getTime() in supporting browsers. \ \ See jsPerf benchmarks: \ http://jsperf.com/date-now-vs-date-gettime \ and \ http://jsperf.com/new-date-value/3 \ \ Enhancement: \ \ now: Date.now || function() { \ return (new Date()).getTime(); \ };Date.now is faster than (new Date()).getTime() in supporting browsers. \ \ See jsPerf benchmarks: \ http://jsperf.com/date-now-vs-date-gettime \ and \ http://jsperf.com/new-date-value/3 \ \ Enhancement: \ {{{ \ now: Date.now || function() { \ return (new Date()).getTime(); \ }; \ }}}
priority: undecidedlow