Improve scroll bottlenecks rules

This commit is contained in:
Gaël Métais
2015-05-07 17:10:01 +02:00
parent 8c79f39389
commit f8f792645b
5 changed files with 40 additions and 12 deletions
+5 -4
View File
@@ -216,7 +216,7 @@ var policies = {
return {
count: offenders.length,
list: offenders.map(function(offender) {
var parts = /^bound by (.*)$/.exec(offender);
var parts = /^bound by (.*) on ([^ ]+)$/.exec(offender);
if (!parts) {
debug('eventsScrollBound offenders transform function error with "%s"', offender);
@@ -228,7 +228,8 @@ var policies = {
var backtraceArray = offendersHelpers.backtraceToArray(parts[1]);
return {
backtrace: backtraceArray || []
backtrace: backtraceArray || [],
target: parts[2]
};
})
};
@@ -239,8 +240,8 @@ var policies = {
"label": "DOM access on scroll",
"message": "<p>This rule counts the number of DOM-accessing functions calls, such as queries, readings, writings, bindings and jQuery functions.</p><p>Two scroll events are triggered quickly, one after the other, and only the second one is analyzed so throttled functions are ignored.</p><p>One of the main reasons of a poor scrolling experience is when too much JS is executed on each scroll event. Note that some devices such as smartphones and MacBooks send more scroll events than others.</p><p>Reduce the number of DOM accesses inside scroll listeners. Put DOM queries outside them when possible. Use <a href=\"http://blogorama.nerdworks.in/javascriptfunctionthrottlingan/\" target=\"_blank\">throttling or deboucing</a>.</p>",
"isOkThreshold": 1,
"isBadThreshold": 10,
"isAbnormalThreshold": 20,
"isBadThreshold": 12,
"isAbnormalThreshold": 25,
"hasOffenders": true,
"offendersTransformFn": function(offenders) {
return offenders;