This isn't necessarily an answer, but you have a Javascript error.
// listen for postMessage events from the notifications iframe
$( window ).on( 'message', function( e ) {
var event = ! e.data && e.originalEvent.data ? e.originalEvent : event;
if ( event.origin !== 'https://widgets.wp.com' ) {
return;
}
var data = ( 'string' === typeof event.data ) ? parseJson( event.data, {} ) : event.data;
if ( 'notesIframeMessage' !== data.type ) {
return;
}
var eventData = notesTracksEvents[ data.action ];
if ( ! eventData ) {
return;
}
recordTracksEvent( eventData( data ) );
} );
It's erroring out on this line specifically (event.origin
is not defined), so it looks like event
is not always an actual event. You should have some type-checking in place. I think this is probably happening before your menu JS kicks in, so it's not actually running properly.
if ( event.origin !== 'https://widgets.wp.com' ) {