Sounds like there’s a problem with image lazyloading, what JS-errors appear on the browser console when “aggregate JS” is active?
I (seemingly) randomly just recently started having a problem with Autoptimize’s Aggregate JS-files setting on one of my sites as well. Most JS on my site suddenly broke with errors that seemed to indicate that some WP core JS wasn’t loading soon enough (_ is undefined
, wp is undefined
, etc.).
I think it may have been due to the changes in scripts included with WordPress 5 but it’s also likely that it was really caused by a change another plugin made as a response to these changes in WP 5 because the issue started happening a few days ago.
After an hour or two of poking around, untying knots, and trying to figure out what was at fault, my fix was eventually adding wp-includes/js/dist
to the Exclude scripts from Autoptimize list. Unfortunately this adds about 30 JS files unaggregated to most pages of the site (in my configuration). A bit drastic, but still better than no aggregation at all I guess.
ah, you’ve fallen victim of a plugin that is very likely doing Gutenburg wrong, inadvertently enqueueing a huge amount of JS-files even if that should not be needed (underscore, wp object JS, …). try finding out which plugin is doing so and urge them to fix that 🙂
frank
update re. doing Gutenberg wrong:
* more info in this blogpost
* you can fix by adding wp-includes/js/dist
to the comma-separated JS optimization exclusion list
* the exclusion will be part of the default settings in the upcoming AO 25
frank