Execution of JavaScript on save post

Do it like shown below, as suggested by @gyo and done by @Howdy_McGee in his answer.

function admin_queue( $hook ) {
    global $post; 
    if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
        if ( 'targeted-posttype' === $post->post_type ) { 
            wp_enqueue_script( 
                'custom-title-here', 
                bloginfo( 'template_directory' ) . '/scripts/custom-script.js', 
                'jquery', 
                '', 
                true 
            );
        }
    }
}
add_action( 'admin_enqueue_scripts', 'admin_queue' );