Drupal : How can I disable all the JavaScript scripts?

 You don't necessarily need to turn off aggregation if you want to remove all javascript. 

function mymodule_preprocess_html(&$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.

1 comment:

Mahesh said...

I have read your complete article. This article is very helpful for me. Please keep posting such types of articles on this website. Thanks For any kinds of Web development
visit our website

Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...