get_theme_mod() only working when the customizer is open

Looks like I was able to fix it by adding a default value at the end of get_theme_mod()

if (  get_theme_mod('my_banner_setting', 1) == 1 ) {

    // proceed

}

Not sure if there’s another solution but this fixed it.

update

Looks like it was actually because my “1” was in quotes, removing the quote worked and I didn’t have to declare the default in get_theme_mod() again.

$wp_customize->add_setting( 'my_banner_setting', array(
    'default'           => 1,
    'sanitize_callback' => 'my_sanitize_checkbox',
) );