How can I disable all the JavaScript scripts?
You don't necessarily need to turn off aggregation if you want to remove all javascript. You could for example remove the placeholder in the html template, then the (already aggregated) javascript won't be replaced in the html page:
function mymodule_preprocess_html(&amp;$variables) {
  if (MODULE_get_headers()) {
    unset($variables['#attached']['html_response_attachment_placeholders']['scripts']);
    unset($variables['#attached']['html_response_attachment_placeholders']['scripts_bottom']);
  }
  $variables['#cache']['contexts'][] = 'headers:my-header';
}

You need a cache context for the request header. This doesn't work for the Internal Page Cache, though. So you need to uninstall this module or extend it to add the request header to the cache key.