-
AuthorPosts
-
December 6, 2022 at 2:22 am #1375172
Hi,
I’ve been doing additional checks for my mobile and it seems Pagespeed reports issue with following javascript:
DNS/wp-includes/js/jquery/jquery.min.js?ver=3.6.1Error: “Does not use passive listeners to improve scrolling performance –
Consider marking your touch and wheel event listeners aspassive
to improve your page’s scroll performance.”Any ideas what is causing this and how to eliminate it? From reading on internet I couldn’t find proper relevant information what is causing this but seems to be theme related. It seems to be reported only for mobile platform. On desktop it did not fire this issue.
Thanks
JaroDecember 7, 2022 at 9:43 am #1375311Hey Jaro,
Thank you for the inquiry.
The warning seems to occur because of the avia_swipe_trigger function in the js > shortcodes.js file. Please edit the shortcodes.js, remove everything, then replace it with the following code.
// https://pastebin.com/d6BJyMEh
Make sure to temporarily disable the Enfold > Performance > File Compression settings and purge the cache after doing the changes above.
Best regards,
IsmaelDecember 7, 2022 at 10:31 am #1375320Thanks Ismael,
I’ve tried this but still same issue happens on my page. I’ve tried to do exactly what you wrote to me. I’ve put back the code which was there before again.
Also do I need to do this every Enfold upgrade or will this be fixed in next version of Enfold?Jaro.
December 8, 2022 at 9:03 am #1375476Hi,
You may need to purge the cache or browser history, or run the speed tool on a different browser to make sure that you are not getting a cached result.
We will probably add the changes in the next patch once we confirmed that it is working. Please provide the WP and FTP details in the private field so that we can test the changes properly.
Best regards,
IsmaelDecember 8, 2022 at 10:31 am #1375495Thanks Ismael,
I’ve tried all of those (clearing cache, browser cache, disable merge/compress, private mode testing) no bueno still.
I’ve deployed my test page to not screw with live one with no plugins and so on. The same issue is there after applying your code. Credentials are in private part.Please check
ThanksDecember 9, 2022 at 8:41 am #1375620Hi,
The slider is not displaying at all in the test page (see private field). Did you change anything?
Best regards,
IsmaelDecember 9, 2022 at 8:52 am #1375621Sorry Ismael,
Please try now. I forgot to revert all the other testing changes I had.December 9, 2022 at 9:49 am #1375632Hi,
We already set all touch and wheel event listeners in the scripts to
passive
but the issue still occurs. Seems to be directly related to the jQuery library. Unfortunately, we are not sure where exactly it is being generated. This is the source of the warning.Source …jquery/jquery.min.js?ver=3.6.1:2:41514(jaro.jamesdk.sk)
This is a library common in any website including WordPress sites.
Best regards,
IsmaelDecember 9, 2022 at 10:08 am #1375635Thanks Ismael for checking it further.
This is a clean install with Enfold and simple full screen slider. Then pagespeed is run.
This should be possible to reproduce easily for developers to debug/fix. Will it be debugged by them or what path forward you see here?Also one thing I noticed it is reported only on mobile phone test not desktop. Maybe specific code for mobile needs to be checked?
Thanks
Jaro.- This reply was modified 2 years ago by Sovietovic.
December 14, 2022 at 10:45 pm #1376232Any ideas what can be done further in this one when it’s easily reproducible? Thanks
December 17, 2022 at 2:11 pm #1376465Hi,
Please see this StackOverflow thread it seems this is a known limitation since 2016 that jQuery can’t add support to passive listeners.
I tested the solution it recommends:jQuery.event.special.touchstart = { setup: function( _, ns, handle ) { this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") }); } }; jQuery.event.special.touchmove = { setup: function( _, ns, handle ) { this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") }); } }; jQuery.event.special.wheel = { setup: function( _, ns, handle ){ this.addEventListener("wheel", handle, { passive: true }); } }; jQuery.event.special.mousewheel = { setup: function( _, ns, handle ){ this.addEventListener("mousewheel", handle, { passive: true }); } };
as a WPCode Code Snippet:
and it passed the Pagespeed report:
Please give this a try.Best regards,
MikeDecember 19, 2022 at 9:14 am #1376669Thanks Mike,
Is the above code to be placed to functions.php of child theme? Or where is proper place to put it?Jaro
December 19, 2022 at 2:36 pm #1376712Hi,
I used the WPCode Code Snippet plugin, if you are using a child theme you could wrap it in a function and add it to your child theme functions.php, but not your parent theme functions.php otherwise you will lose it on your next update.
In a child theme functions.php you would add this:function support_for_passive_listeners() { ?> <script> window.addEventListener('DOMContentLoaded', function() { jQuery.event.special.touchstart = { setup: function( _, ns, handle ) { this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") }); } }; jQuery.event.special.touchmove = { setup: function( _, ns, handle ) { this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") }); } }; jQuery.event.special.wheel = { setup: function( _, ns, handle ){ this.addEventListener("wheel", handle, { passive: true }); } }; jQuery.event.special.mousewheel = { setup: function( _, ns, handle ){ this.addEventListener("mousewheel", handle, { passive: true }); } }; }); </script> <?php } add_action('wp_footer', 'support_for_passive_listeners');
I tested this and it passed the Pagespeed report.
Best regards,
MikeDecember 20, 2022 at 11:33 am #1376851Thanks a lot Mike,
This seems to work fine and passed the test now.
Can you please create ticket for developers to fix this in theme so we don’t need to do these hacks in future? I expect more people will start to complain about this issue.Jaro.
December 20, 2022 at 1:28 pm #1376875Hi,
Glad we were able to help, I will refer this thread to the Dev Team for their review. If you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Pagespeed – Does not use passive listeners’ is closed to new replies.