Adding javascript blocks to a single file and adding it to the header

Just chuck them in a file, say your-theme/js/global.js and enqueue it in functions.php: function wpse_180397_scripts() { wp_enqueue_script( ‘wpse-180397-global’, /* Unique ID */ get_bloginfo( ‘template_url’ ) . ‘/js/global.js’, /* URL */ array(), /* Dependencies */ true /* In footer */ ); } add_action( ‘wp_enqueue_scripts’, ‘wpse_180397_scripts’ );

Receive “menu-toogle” event from section menu in customizer

So far the only solution I’ve come up with is creating a function that postMessages the event into the iframe (using customize_controls_enqueue_scripts hook). As for the receiver in iframe (hooked on customize_preview_init hook) I think it could still need some optimization because I’m getting a weird issue with window.addEventListener(‘message’,* getting some duplicate on customizer loading.. … Read more