How to enqueue javascript for WP Customize options sidebar?

I’m trying to add Chosen.jquery to the WP Customize options panel, so I can have an autocomplete box there. Is there any way I can do that? I tried with admin_init, admin_footer and admin_print_footer_scripts actions, but none seems to work inside of the Customizer.

Any thoughts?

Related posts

2 comments

  1. Use the action customize_controls_enqueue_scripts:

    add_action( 
        'customize_controls_enqueue_scripts', 
        'enqueue_customizer_scripts' 
    );
    
    function enqueue_customizer_scripts()
    {
        wp_enqueue_script(); // fill in the details here
    }
    

    To add inline scripts in the header, use the action customize_controls_print_scripts.

    See wp-admin/customize.php for details.

Comments are closed.