Disable Javascript Aggregation on specific pages

Disable Javascript Aggregation on specific pages

26 December 2009 by jay boodhun Disable Javascript Aggregation on specific pages 1 Comments

Optimising Drupal sites by reducing the overheads of numerous css files and js files spit out by modules can be done using the following modules:

However, aggregating Javascript which also Gzip and minifies all js files into one may case some problems as TinyMCE or FCK Editor and some jquery functionalities like expand / Collapse might not work.

These features are mostly used in the admin section. so to work round this we can hook into the Drupal preprocessor to turn off aggregation on the admin specific pages:

use the hook_init() in a custom module as follows:

 


function my_module_init() { 
	$uri_path = trim($_SERVER['REQUEST_URI'], '/');
	$uri_parts = explode('/', $uri_path);
	if($uri_parts[0] == 'admin') { // Disables javascript pre process in all admin pages
	   global $conf;
           $conf['preprocess_js'] = FALSE;
	}
} 

Does this also work with the core js optimization?

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Syntax highlight code surrounded by the {syntaxhighlighter OPTIONS}...{/syntaxhighlighter} tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.