In wordpress customizer div still showing even if I hid it with javascript

if anyone faces this in future: thanks to @SallyCJ i was able to solve the issue by adding css style to the customize_preview_init hook.
Here’s the code:

add_action( 'customize_preview_init', function() {

    wp_enqueue_script( 'cutomizer-preview', get_template_directory_uri() . '/dist/assets/js/customize-preview.js', array('customize-preview', 'jquery'), time() , true );

    if ( !get_theme_mod( '_themename_display_author_info', true ) ) :
        add_action( 'wp_head', function() {
            echo '<style>#author-info{display:none;}</style>';
        }  );
    endif;

} );