Best solution would be for the video-opening JS not relying on jQuery to be honest π
But if that’s not possible, try changing AO settings to “don’t aggregate but defer” and “also defer inline JS” and then remove existing exclusions unless things break?
I have done that (I think) and still not working?
I now have lots of smaller js files rather than one large one…
Can’t really change the js relying on jquery.
Still no video though. π
Looks like the jQuery-dependant inline JS that adds the event listener is excluded from being optimized (deferred). If you don’t have any exclusions any more in the settings, then it’s the plugin (theme) that is forcing the exclusion somehow in which case I’m afraid you’re stuck .. :-/
OK I had not taken out the exclusions – now this seems to work OK, however, Lighthouse is now saying that my javascript execution time is slightly higher than before, but the error message to reduce unused javascript has disappeared.
I will have to see if the core web vitals in search console approves of the change to multiple js files instead of one large one.
What’s you experience of this? Better/worse or the same?
Unfortunately I have a page that will not load at all with the ‘do not aggregate but defer’ option ticked so had to revert: https://www.truckpages.co.uk/add-a-truck/
Hmm … what JS error(s) did you see on the browser console while on that page when “don’t aggregate but defer” was active?
ah … that’s … ugly. can you check the PHP-errorlog for relevant PHP errors?
An odd one – it seems not to be able to download even the favicon before falling over?
200 GET /add-a-truck/ HTTP/1.0
302 GET /favicon.ico HTTP/2.0
51363#0: *250519 open() “/var/www/vhosts/truckpages.co.uk/httpdocs/favicon.ico” failed (2: No such file or directory) nginx error
Then with AO off:
GET /add-a-truck/?ao_noptimize=1 HTTP/1.0
GET /wp-admin/js/editor.min.js?ver=5.8.1 HTTP/2.0
GET /wp-content/themes/motors/assets/images/checks2x.png HTTP/2.0
Looks like that admin js file is not being called?
that’s a consequence of only very little HTML being returned when “donβt aggregate but defer” is active, a pity the PHP errorlog does not show more then that, makes it pretty hard to understand what is going on there.
I looked at the unoptimized page source and there’s a huge block of inline JS (setting the options object) which, I presume due to the size of it, is killing the “also defer inline JS”-option.
the easy way out: make sure “Enable configuration per post/ page?” is on, then edit the “add a truck” page and untick “optimize JS” there. that way you can “enjoy” all JS being deferred plus a working “add a truck”-page (albeit the latter not being JS-optimized)?