Improve scroll bottlenecks rules
This commit is contained in:
@@ -41,7 +41,7 @@ exports.module = function(phantomas) {
|
||||
// count window.addEventListener('scroll', ...) - issue #508
|
||||
if (eventType === 'scroll' && (path === 'window' || path === '#document')) {
|
||||
phantomas.incrMetric('eventsScrollBound');
|
||||
phantomas.addOffender('eventsScrollBound', 'bound by %s', phantomas.getBacktrace());
|
||||
phantomas.addOffender('eventsScrollBound', 'bound by %s on %s', phantomas.getBacktrace(), path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,4 +67,16 @@ exports.module = function(phantomas) {
|
||||
})(window.__phantomas);
|
||||
});
|
||||
});
|
||||
|
||||
phantomas.on('report', function() {
|
||||
phantomas.evaluate(function() {
|
||||
(function(phantomas) {
|
||||
// Check if a window.onscroll function is defined
|
||||
if (typeof(window.onscroll) === "function") {
|
||||
phantomas.incrMetric('eventsScrollBound');
|
||||
phantomas.addOffender('eventsScrollBound', 'bound by %s on %s', '', 'window.onscroll');
|
||||
}
|
||||
}(window.__phantomas));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -32,13 +32,7 @@ exports.module = function(phantomas) {
|
||||
});
|
||||
window.dispatchEvent(evt);
|
||||
|
||||
// 3. onscroll()
|
||||
if (window.onscroll) {
|
||||
phantomas.pushContext({
|
||||
type: 'window.onscroll'
|
||||
});
|
||||
window.onscroll();
|
||||
}
|
||||
// No need to call window.onscroll(), it's called by the scroll event on window
|
||||
|
||||
} catch(e) {
|
||||
phantomas.log('ScrollListener error: %s', e);
|
||||
|
||||
Reference in New Issue
Block a user