I have a site that also serves its content to mobile devices. As these sites(desktop/mobile) uses same code. I have a problem in performance since the modules being used in desktop site is also loaded in mobile site even if I'm not using it. Is there a way to excludes those modules(custom/contrib) without hacking each modules? Any good idea in this kind of situation?
Hi Patrick...something like this code I created so far...but I'm not sure if this is feasible.
function array_search_regex($pattern, $array) {
for($x = 0; $x < count($array); $x++) {
if(preg_match($pattern, $array[$x])) {
return true;
}
}
return false;
}
//Collect all css and place in an array
$get_all_css = array();
$get_all_css = drupal_get_css();
//Put the return html styles in an array
$ret_all_css = explode("\n", $get_all_css);
//Get the array index of the matched in the search
//$lookup_css = array_search('<link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?G" />', $ret_all_css);
$lookup_css = array_search_regex("/<link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"\/modules\/node\/node.css\?.\" \/>/", $ret_all_css);
//Unset the searched styles.
unset($ret_all_css[$lookup_css]);
//Return all essential styles. This should replace $styles in page.tpl.php
$styles = implode("\n", $ret_all_css);