Disable modules when browsing mobile site 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 &lt; 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('&lt;link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?G" /&gt;', $ret_all_css);
    $lookup_css = array_search_regex("/&lt;link type=\"text\/css\" rel=\"stylesheet\" media=\"all\" href=\"\/modules\/node\/node.css\?.\" \/&gt;/", $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);
The load caused by modules is handled by the server, so merely having the modules enabled will not affect the performance of your mobile site.  In any case, it is impossible to disable the modules because you could be serving web pages to both mobile and desktop machines at the same time.

Instead, what you want to do is add a mobile theme.  There are lots of ways to do this but the Mobile Tools module is a good way to get started.

For a more specific solution, you'll have to identify which modules are causing the performance problems on your site so that workarounds can be found.