Please note the below is done via a custom plugin and not in the functions file as most themes when updated will overwrite the functions file.
The below is tested and works to unqueue a script, I have added code that you can use to test if the file is loaded prior to removing it and also I would use your custom post name if you only wish this to be unloaded on that post type in is_singular().
<?php
/*
Plugin Name: Remove_script_Stack_353322
Plugin URI: www.mywebsite.com
Description: Remove a script when needed
Version: 1.0
Author: Me
Author URI: www.mywebsite.com
*/
/**
* Enqueue script.
*/
function my_scripts_method() {
//Change your plugin url/name
wp_enqueue_script( 'gdrts-rating', plugins_url( 'test.js' , __FILE__ ));
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
function wpdocs_dequeue_script()
{
// Lets check if gdrts-rating is loaded
$handle="gdrts-rating";
$list="enqueued";
if (wp_script_is( $handle, $list ))
{
//echo 'Loaded --------------------------------------------------------------------->';
// Custom post type so use the name in -> is_singular('custom_post_name') you can have more post types such as is_singular('custom_post_name', 'custom_post_2')
if (is_singular())
{
// Unload the plugin
wp_dequeue_script( 'gdrts-rating' );
}
}
else
{
// Not loaded do nothing
//echo 'Not loaded --------------------------------------------------------------------->';
}
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 10 );