Skip to content

[Experimental] Mobile hamburger menu breaks when JS optimization/delay plugins leave NeveProperties undefined #4526

Description

@ineagu

Summary

The frontend mobile-menu toggle handler reads the global NeveProperties object without checking that it exists. When a JavaScript optimization/delay plugin (combine, defer, or "delay JS until interaction") prevents the localized NeveProperties data from being defined before the main frontend bundle runs, tapping the hamburger icon throws an unhandled TypeError (Cannot read properties of undefined (reading 'isCustomize')) and the off-canvas menu never opens.

The menu markup and CSS are unaffected — manually adding the is-menu-sidebar class to <body> opens the panel — which indicates the click/touch handler is aborting rather than a styling/markup problem.

Customer context

Several WordPress.org forum reports describe the Neve mobile hamburger icon doing nothing when tapped, most visibly on Safari iOS, while desktop and other mobile browsers work normally. In each case the affected site ran a performance/caching plugin that optimizes or delays JavaScript (SiteGround Speed Optimizer in the recent reports; an earlier email report named Breeze / Varnish / Cloudflare). Adjusting or disabling the JS-optimization settings restored the menu.

Reproduction or evidence

Code path (current default branch):

  • assets/js/src/frontend/app.js — on window load, run() calls window.HFG = new HFG(), which binds the click handler on .menu-mobile-toggle.
  • assets/js/src/frontend/hgf.js, HFG.prototype.toggleMenuSidebar — the handler evaluates !NeveProperties.isCustomize && doc.body.classList.contains(...). NeveProperties is a global expected to be present (/* global NeveProperties */ at the top of the file). If it is undefined at click time, reading .isCustomize throws before the open path runs.

Repro steps:

  1. Neve site using the mobile header / hamburger menu.
  2. Activate a JS-optimization plugin and enable JS combine + defer/delay, then clear caches so the optimized assets are actually served.
  3. On a phone (Safari iOS reported), tap the hamburger icon → nothing happens. Browser console shows TypeError: Cannot read properties of undefined (reading 'isCustomize').
  4. Run document.body.classList.add('is-menu-sidebar') in the console → the panel opens, confirming markup/CSS are fine and only the JS handler is failing.

Suggested hardening (matching a reporter's recommendation): guard the access with typeof NeveProperties === 'undefined' or optional chaining (NeveProperties?.isCustomize) so the toggle degrades gracefully when the localized data has not loaded yet. Hardening the global access would prevent this class of mobile-menu breakage across all JS-optimization/caching plugins, not just one.

Source

  • Surfaced by: Codeinwp/docs-site#1570
  • Forum/HelpScout thread(s): forum topic captured as 3368047745 / 3368103174 (Safari iOS, Neve 4.2.4–4.2.5); earlier email thread 3297248497 (Neve 4.2.3, precise diagnosis tracing the unhandled TypeError in toggleMenuSidebar)
  • Helpdesk pattern: one current forum case (captured under several conversation IDs) plus one earlier, independent email report of the same class
  • Reviewer classification: bug

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions