See wp_enqueue_script() for the information how to add scripts without editing the HTML.
I assume the script is already registered or you’ll add all necessary parameters.
Tied to the particular page ID:
if( is_page($page_id) ) { // provide the page ID
wp_enqueue_script('YOUR_SCRIPT_NAME'); //enqueue the script on success
}
Tied to the page slug:
$slug = get_post_field( 'post_name', get_post() ); // get the page slug
if('the-very-same-page-slug' == $slug) { // compare the slug against the very same
wp_enqueue_script('YOUR_SCRIPT_NAME'); //enqueue the script on success
}
Tied to the page custom field (preferred):
$cf = get_post_field( 'CUSTOM_FIELD_NAME', get_post() ); // get the custom field
if( !empty($cf) ) { // see if the field exists or non-empty
wp_enqueue_script('YOUR_SCRIPT_NAME'); //enqueue the script on success
}
You can create your own plugin to be independent of the theme. See Plugin Handbook for more.