Check if a sidebar is present
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
global $wp_registered_sidebars;
if ( isset( $wp_registered_sidebars['header-right'] ) ) {
wp_enqueue_script( 'sticky-nav-script', get_stylesheet_directory_uri() . '/js/sticky-nav.js', array('jquery'), '1.0.0' );
}