Skip to content

Commit 1b9940d

Browse files
committed
Make the min number of event lag samples before completion configurable, and lower the default to 10. Fixes CodeByZach#5.
1 parent 8f5c7cf commit 1b9940d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

pace.coffee

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ defaultOptions =
3434

3535
# What elements should we wait for before deciding the page is fully loaded (not required)
3636
selectors: ['body']
37+
38+
eventLag:
39+
# When we first start measuring event lag, not much is going on in the browser yet, so it's
40+
# not uncommon for the numbers to be abnormally low for the first few samples. This configures
41+
# how many samples we need before we consider a low number to mean completion.
42+
minSamples: 10
3743

3844
now = ->
3945
performance?.now?() ? +new Date
@@ -325,7 +331,7 @@ class EventLagMonitor
325331

326332
avg = avg + (diff - avg)/15
327333

328-
if points++ > 20 and Math.abs(avg) < 3
334+
if points++ > options.eventLag.minSamples and Math.abs(avg) < 3
329335
avg = 0
330336

331337
@progress = 100 * (3 / (avg + 3))

pace.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pace.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)