Commenting out unwated CSS/scripts in HTML with PHP

Install Query Monitor to show your scripts and styles (#qm-assets) – specifically the ID used to register the scripts/styles.

Then hook wp_print_scripts and use wp_dequeue_script() to remove it before it outputs.

/**
 * Dequeue the jQuery UI script.
 *
 * Hooked to the wp_print_scripts action, with a late priority (100),
 * so that it is after the script was enqueued.
 */
function wpdocs_dequeue_script() {
   wp_dequeue_script( 'jquery-ui-core' );
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );

You can also wrap your wp_head with ob_start() (PRI 0) and ob_get_clean() (PRI PHP_INT_MAX) to run str_replace() if you know the exact output.