Skip to main content

Bug Tracker

Side navigation

#2550 closed enhancement (fixed)

Opened March 19, 2008 02:07AM UTC

Closed April 22, 2008 01:22AM UTC

Last modified May 15, 2008 02:46PM UTC

Try removing with() from offset.

Reported by: flesler Owned by: brandon
Priority: minor Milestone: 1.2.4
Component: offset Version: 1.2.3
Keywords: offset with Cc:
Blocked by: Blocking:
Description

Maybe, removing the with() call from offset() can improve its perfomance. The saving in bytes is really small, so if it does hit on perfomance, then it might be better to remove it.

Attachments (3)
  • offset-curCSS-getComp.diff (3.5 KB) - added by flesler March 19, 2008 04:09AM UTC.

    Replacing css for curCSS inside offset, caching getComputedStyle

  • offset.diff (2.3 KB) - added by flesler March 19, 2008 02:08AM UTC.

    with() removed, jQuery browser is cached into a variable

  • test.js (0.4 KB) - added by flesler March 19, 2008 01:59PM UTC.

    File to run the tests

Change History (3)

Changed March 19, 2008 04:17AM UTC by flesler comment:1

I made some real tests, the with() didn't seem to matter much.

I tried replacing jQuery.css for jQuery.curCSS because that was a useless call. The time got lower and saved many calls.

Then cached document.defaultView && document.defaultView.getComputedStyle in a var, and that reduced the time.

I tried all this many many times back and forth to discard CPU interferences.

The element that I called offset on, had 7 parents, and then the body. The latter was its third offsetParent.

Regular

Profile (21359.375ms, 186011 calls)
offset(500 times) - attempt 1: 5359ms test.js (line 17)
offset(500 times) - attempt 2: 5406ms test.js (line 17)
offset(500 times) - attempt 3: 5359ms test.js (line 17)
offset(500 times) - attempt 4: 5297ms

curCSS 4 css 

Profile (20296.875ms, 148011 calls)
offset(500 times) - attempt 1: 5093ms test.js (line 17)
offset(500 times) - attempt 2: 5000ms test.js (line 17)
offset(500 times) - attempt 3: 5109ms test.js (line 17)
offset(500 times) - attempt 4: 5109ms

curCSS 4 css, defaultView cached

Profile (16203.125ms, 148011 calls)
offset(500 times) - attempt 1: 3984ms test.js (line 17)
offset(500 times) - attempt 2: 3969ms test.js (line 17)
offset(500 times) - attempt 3: 4078ms test.js (line 17)
offset(500 times) - attempt 4: 4203ms

Changed April 22, 2008 01:22AM UTC by brandon comment:2

resolution: → fixed
status: newclosed

Patch applied in [5274] and [5275].

Changed May 15, 2008 02:46PM UTC by flesler comment:3

Added some modifications to this at [5609].