WordPress 5.5 – ReferenceError: commonL10n is not defined error

This is Trac ticket 51223: commonL10n and other JS globals removed without backwards compatibility In WordPress 5.5, the localized translations under commonL10n were replaced by wp.i18n.__ without deprecation notice or backwards compatibility. Plugins using commonL10n now have JavaScript errors introduced by updating WordPress which can break site functionality. It was fixed in 5.5.1 by adding … Read more

wp.customize.bind ready event not fired

Do not put the Customizer ready event handler inside of the jQuery event handler. The Customizer ready will trigger at jQuery ready, so you are adding the event handler too late. Just do: wp.customize.bind(‘ready’, function(){ console.log(‘ready’); }); Your JS needs to be enqueued with customize-controls script as its dependency. Enqueue at the customize_controls_enqueue_scripts action.

Any advantage of using wp_scripts and is_IE when enqueuing scripts

To extend on @gmazzap suggestion on not using globals when you can use wp_scripts(), there is a shortcut for wp_scripts() for adding conditional comments called wp_script_add_data and likewise wp_style_add_data for conditional styles. So the correct way to use conditionals as of WordPress 4.2 is like this: /** * IE enqueue HTML5shiv with conditionals * @link … Read more

How to dequeue a script?

There is a dequeue method available … I’m just not sure why it isn’t wrapped in a wp_dequeue_script() method. (I might create a ticket for this issue, actually) But yes, using wp_deregister_script will accomplish what you’re trying to do. Just remember, if you ever do want to use WP’s built-in jQuery later you’ll need to … Read more

wp_enqueue_script() not working at all

wp_enqueue_style and wp_enqueue_script accepts many parameters and it’s very important to use them in correct order otherwise these functions will fail. Here are complete set of parameters for each function. wp_enqueue_style( $handle, $src, $deps, $ver, $media ); wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); In your wp_enqueue_style you define $handle, $src correctly but $deps to … Read more