Overview
A client running a Divi-based WordPress site reported that their mega menu was flashing or flickering briefly on page load. The issue occurred on the live production site and could be replicated in incognito mode, meaning browser extensions or cookies were not to blame.
Freshy’s development team diagnosed the issue as a JavaScript execution delay caused by WP Rocket’s optimization settings. The fix involved excluding Divi’s menu scripts from WP Rocket’s optimization rules, restoring a stable menu experience while maintaining overall site performance.
Issue background
The client noticed a visual flicker on every page load where the site’s mega menu was visible. This “flash” appeared as the unstyled HTML version of the menu displayed briefly before Divi’s JavaScript applied its dynamic styling.
Because the site used WP Rocket for caching and performance optimization, this behavior only appeared after enabling WP Rocket’s minification and combination features. When caching was temporarily disabled, the issue disappeared, confirming that optimization was interfering with the Divi menu’s JavaScript loading order.
Diagnosis
Freshy’s developer tested the behavior in multiple browsers (Chrome, Firefox, and Safari) and confirmed:
- The flicker occurred before Divi’s scripts finished initializing.
- The issue persisted even after clearing cache and disabling lazy loading for images and iframes.
- Console inspection showed delayed execution of
et_core_page_resource_fallback, a Divi script responsible for applying final menu styles.
Further testing revealed that WP Rocket’s “Combine JavaScript Files” and “Delay JavaScript Execution” options were deferring Divi’s navigation script (scripts.min.js) until after the DOM fully loaded. This caused a visible flash of unstyled content (FOUC).
Resolution steps
- Identify conflicting scripts – Inspected WP Rocket’s optimization log to confirm that Divi’s
scripts.min.jsandet-core-unified-deferred.jswere being minified and delayed. Verified that removing those files from optimization restored menu stability. - Exclude Divi scripts from WP Rocket optimization – In WP Rocket settings under File Optimization → Excluded JavaScript Files, added the following exclusions:
/wp-content/themes/Divi/js/scripts.min.js
/wp-content/themes/Divi/core/scripts/frontend-builder-scripts.js
/wp-content/themes/Divi/core/admin/js/common.js
et-core-unified-deferred.js
This ensured Divi’s core scripts were loaded immediately on page render.
- Purge and rebuild cache – Cleared WP Rocket cache and regenerated minified CSS/JS files. Emptied browser and server caches to eliminate residual assets.
- Test performance impact – Reran speed tests using Google PageSpeed Insights and GTmetrix. Confirmed no measurable drop in load speed after the exclusions. Verified that the flicker was completely gone on both desktop and mobile.
- Implement fallback monitoring – Enabled WP Rocket’s “Safe Mode for Minification” to prevent future script conflicts after updates. Documented the excluded scripts for internal reference.
Final outcome
After excluding Divi’s JavaScript files from WP Rocket optimization, the flickering mega menu issue was resolved entirely. The menu now loads smoothly with no flashing or delay on page load, even in incognito mode.
This adjustment preserved site performance benefits from caching while ensuring proper front-end rendering of Divi’s JavaScript-driven components.
Key takeaways
- Caching and optimization plugins like WP Rocket can sometimes conflict with builder themes like Divi when deferring key JavaScript files.
- Always test visually dynamic elements such as mega menus, sliders, and animations after enabling minification or delay options.
- Excluding specific scripts from optimization is often a safe and effective fix that preserves performance.
- Keeping a record of excluded files helps prevent issues after plugin or theme updates.
Is your WordPress site showing layout flickers or animation delays after enabling caching?
Contact Freshy for expert Divi and WP Rocket optimization support.