Forum Moderators: open

Message Too Old, No Replies

Does not use passive listeners to improve scrolling performance

Does not use passive listeners

         

anthonyinit

11:47 pm on Jul 6, 2020 (gmt 0)

10+ Year Member



Hello All,
I'm doing some speed test with "PageSpeed Insights"

I'm seeing error message "Does not use passive listeners to improve scrolling performance" Consider marking your touch and wheel event listeners as `passive` to improve your page's scroll performance.
/js/jquery.min.js line: 1221

line: 1221 looks like this
     (s = rt.exec(n[l]) || []),
(g = y = s[1]),
(m = (s[2] || "").split(".").sort()),
(p = b.event.special[g] || {}),
(g = (a ? p.delegateType : p.bindType) || g),
(p = b.event.special[g] || {}),
(d = b.extend({ type: g, origType: y, data: o, handler: r, guid: r.guid, selector: a, needsContext: a && b.expr.match.needsContext.test(a), namespace: m.join(".") }, c)),
(h = u[g]) || ((h = u[g] = []), (h.delegateCount = 0), (p.setup && p.setup.call(e, o, m, f) !== !1) || (e.addEventListener ? e.addEventListener(g, f, !1) : e.attachEvent && e.attachEvent("on" + g, f))),
p.add && (p.add.call(e, d), d.handler.guid || (d.handler.guid = r.guid)),
a ? h.splice(h.delegateCount++, 0, d) : h.push(d),
(b.event.global[g] = !0);
e = null;
}
},


When I check help it tells me to add this line
document.addEventListener('touchstart', onTouchStart, {passive: true});


Can anyone help me edit this code, please

Thank you

Beuge

8:04 pm on Jul 10, 2020 (gmt 0)

5+ Year Member



The code you posted is part of the jquery library. I might be wrong, but I don't think you'll find anybody on this forum who wants to fiddle with that.

As a work around you could add the event which is causing the problem with plane javascript instead of using jquery. Or just ignore the message, it's a warning not an error.

You can't even use the passive mode, if you want your event function to prevent the default browser action with event.preventDefault(). But you will still get the warning.

anthonyinit

9:41 pm on Jul 11, 2020 (gmt 0)

10+ Year Member



@beuge Thank you for your reply, well, in that case, I will ignore this warning message.