Title: Cannot optimize mobile theme
Last modified: August 31, 2016

---

# Cannot optimize mobile theme

 *  [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/)
 * Hi!
 * Installed AO 2.0.2.
    I’m using custom mobile swithing plugin: it detects mobile
   browsers and switches to mobile WP theme. The problem is: AO works fine on desktop
   version ([http://dev2.kuponarama.ru/](http://dev2.kuponarama.ru/)) but on mobile(
   [http://m.dev2.kuponarama.ru/](http://m.dev2.kuponarama.ru/)) it works only for
   html and inlined CSS and JS – so it cannot optimize external CSS (for example
   with URL “/wp-content/themes/mobile/css/all.css”).
 * Some theme switching code:
 *     ```
       case "m.dev2.kuponarama.ru":
       			define('WP_HOME', 'http://m.dev2.kuponarama.ru');
       			define('WP_SITEURL','http://m.dev2.kuponarama.ru');
       			//define('WP_CONTENT_URL','http://m.dev2.kuponarama.ru/wp-content');
       			break;
       ```
   
 * Changing theme:
 *     ```
       /**
        * @return mobile theme name
        */
       function kuponarama_getMobileTheme() {
       	switch($_SERVER["HTTP_HOST"]) {
       		case "m.kuponarama.ru":
       		case "m.dev.kuponarama.ru":
       		case "m.dev2.kuponarama.ru":
       			return "mobile";
       		case "dev.kuponarama.ru":
       		case "kuponarama.ru":
       		case "www.kuponarama.ru":
       			return "clipper-child";
       	}
       }
   
       function ts_get_template($template) {
       	$theme = kuponarama_getMobileTheme();
       	if (empty($theme)) {
       		return $template;
       	}
       	$theme = ts_get_one_theme($theme);
       	if (empty($theme)) {
       		return $template;
       	}
       	// Don't let people peek at unpublished themes.
       	if (isset($theme['Status']) && $theme['Status'] != 'publish')
       	return $template;
       	return $theme['Template'];
       }
       add_filter('template', 'ts_get_template');
   
       function ts_get_stylesheet($stylesheet) {
       	$theme = kuponarama_getMobileTheme();
       	if (empty($theme)) {
       		return $stylesheet;
       	}
       	$theme = ts_get_one_theme($theme);
       	// Don't let people peek at unpublished themes.
       	if (isset($theme['Status']) && $theme['Status'] != 'publish')
       	return $stylesheet;
       	if (empty($theme)) {
       		return $stylesheet;
       	}
       	return $theme['Stylesheet'];
       }
       add_filter('stylesheet', 'ts_get_stylesheet');
   
       // helper function to replace get_theme()
       function ts_get_one_theme($theme) {
       	$themes = wp_get_themes();
       	if (array_key_exists($theme, $themes))
       	return $themes[$theme];
       	return NULL;
       }
       ```
   
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/page/2/?output_format=md)

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295144)
 * AO doesn’t aggregate JS/ CSS if it’s not on the same domain, so you’ll have to
   feed the alternate domains to AO using the `autoptimize_filter_cssjs_multidomain`
   filter (array $in, return array $out).
 * hope this helps,
    frank
 *  Thread Starter [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295148)
 * Just added filter, no luck.
 * I have relative css URLs like this: “/wp-content/themes/mobile/css/all.css” without
   domain.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295160)
 * relative URL’s are normally aggregated as well … don’t see any sign of autoptimize
   on [http://m.dev2.kuponarama.ru/](http://m.dev2.kuponarama.ru/) actually, not
   even for inline code?
 * frank
 *  Thread Starter [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295202)
 * I’ve enabled inline code optimization. You can see optimized JS file.
 * My CSS and JS links are located in wrapper.php in mobile theme. They are plain
   text, no PHP code.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295232)
 * does the linked CSS/ JS get autoptimized if you use the mobile theme as the default
   theme for desktop as well (so without it being called by your mobile detection
   code)?
 * frank
 *  Thread Starter [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295296)
 * Still no luck. Tried changing default theme to mobile version – no optimization
   on mobile domain (m.dev2.kuponarama.ru/).
    Then using desktop domain dev2.kuponarama.
   ru – everything works fine even with mobile theme.
 * Nick.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295299)
 * OK, looks like a domain mismatch error anyhow; AO prepends your relative URL’s
   with the site-url, which is probably different from the current URL.
 * Can you overwrite wp-content/plugins/autoptimize/classes/autoptimizeBase.php 
   with [this version](https://gist.github.com/futtta/8fac82f93e22e4a56252) and 
   then check your php error log for debug messages?
 * frank
 *  Thread Starter [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295314)
 * Got some debug info:
 *     ```
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL before normalization: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL after normalization: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
       [20-Apr-2016 09:18:41] autoptimize debug: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js does not match host in ajax.googleapis.com
       [20-Apr-2016 09:18:41] autoptimize debug: getpath got multidomains but no dice for https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 09:18:41] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:41] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 09:18:41] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:41] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/search.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 09:18:41] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:41] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 09:18:41] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:41] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL before normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL after normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 09:18:41] autoptimize debug: http://counter.rambler.ru/top100.jcn does not match host in counter.rambler.ru
       [20-Apr-2016 09:18:41] autoptimize debug: getpath got multidomains but no dice for http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/css/all.css
       [20-Apr-2016 09:18:41] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       [20-Apr-2016 09:18:41] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:41] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL before normalization: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL after normalization: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
       [20-Apr-2016 09:18:43] autoptimize debug: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js does not match host in ajax.googleapis.com
       [20-Apr-2016 09:18:43] autoptimize debug: getpath got multidomains but no dice for https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 09:18:43] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:43] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 09:18:43] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:43] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/search.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 09:18:43] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:43] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 09:18:43] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:43] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL before normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL after normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 09:18:43] autoptimize debug: http://counter.rambler.ru/top100.jcn does not match host in counter.rambler.ru
       [20-Apr-2016 09:18:43] autoptimize debug: getpath got multidomains but no dice for http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/css/all.css
       [20-Apr-2016 09:18:43] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       [20-Apr-2016 09:18:43] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 09:18:43] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       ```
   
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295318)
 * this is the relevant entry;
 * > [20-Apr-2016 09:18:41] autoptimize debug: path for [http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js](http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js)
   > is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js using
   > tmp_ao_root ://dev2.kuponarama.ru
 * tmp_ao_root is based on content_url(), which in this case apparently returns 
   dev2.kuponarama.ru which does not match m.dev2.kuponarama.ru
 * as a quick workaround/ test, can you set m.dev2.kuponarame.ru as CDN in AO settings?
 * frank
 *  Thread Starter [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295319)
 * After setting CDN [http://m.dev2.kuponarama.ru](http://m.dev2.kuponarama.ru):
 *     ```
       [20-Apr-2016 10:26:22] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 10:26:22] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:26:22] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/search.js
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 10:26:22] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:26:22] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 10:26:22] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:26:22] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL before normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL after normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 10:26:22] autoptimize debug: http://counter.rambler.ru/top100.jcn does not match host in counter.rambler.ru
       [20-Apr-2016 10:26:22] autoptimize debug: getpath got multidomains but no dice for http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/css/all.css
       [20-Apr-2016 10:26:22] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       [20-Apr-2016 10:26:22] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:26:22] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       ```
   
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295320)
 * > After setting CDN [http://m.dev2.kuponarama.ru](http://m.dev2.kuponarama.ru):
 * in Autoptimize’s settings? because I still see
 * `<script type="text/javascript" defer src="http://dev2.kuponarama.ru/wp-content/
   cache/autoptimize/js/autoptimize_653291585ab021db96c3bc704d4d5796.js"></script
   >`
 * on m.dev2.kuponarama.ru, which seems to indicate the CDN is not set in AO?
 * frank
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295321)
 * actually, changing
 *     ```
       case "m.dev2.kuponarama.ru":
       			define('WP_HOME', 'http://m.dev2.kuponarama.ru');
       			define('WP_SITEURL','http://m.dev2.kuponarama.ru');
       			//define('WP_CONTENT_URL','http://m.dev2.kuponarama.ru/wp-content');
       			break;
       ```
   
 * into
 *     ```
       case "m.dev2.kuponarama.ru":
       			define('WP_HOME', 'http://m.dev2.kuponarama.ru');
       			define('WP_SITEURL','http://m.dev2.kuponarama.ru');
       			define('WP_CONTENT_URL','http://m.dev2.kuponarama.ru/wp-content');
       			break;
       ```
   
 * (so forcing wp_content_url to the correct domain) could be enough to fix this.
 *  Thread Starter [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295322)
 * After setting CDN in AO settings and changing WP_CONTENT_URL still the same:
 *     ```
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 10:51:18] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:51:18] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/jquery.main.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 10:51:18] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:51:18] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/libs/sly.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/search.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 10:51:18] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:51:18] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 10:51:18] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:51:18] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/js/loadStyles.js
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL before normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL after normalization: http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 10:51:18] autoptimize debug: http://counter.rambler.ru/top100.jcn does not match host in counter.rambler.ru
       [20-Apr-2016 10:51:18] autoptimize debug: getpath got multidomains but no dice for http://counter.rambler.ru/top100.jcn
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL before normalization: /wp-content/themes/mobile/css/all.css
       [20-Apr-2016 10:51:18] autoptimize debug: getpath URL after normalization: http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       [20-Apr-2016 10:51:18] autoptimize debug: path for http://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css is ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css using tmp_ao_root ://dev2.kuponarama.ru
       [20-Apr-2016 10:51:18] autoptimize debug: getpath considers not local as path still starts with :// ://m.dev2.kuponarama.ru/wp-content/themes/mobile/css/all.css
       ```
   
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295329)
 * In that case I can only conclude that AO doesn’t work with dynamically switched
   themes I’m afraid; both setting the WP_CONTENT_URL and setting a CDN in AO should
   allow it to pick up the JS/ CSS-files.
 * What you could try next is setting the URL’s of the CSS & JS to include the full
   main domain, so you’d have;
 * `http://dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js`
    instead of`/
   wp-content/themes/mobile/js/search.js`
 * While thinking about this; it is possible your theme switching code somehow messes
   up the way AO gets called, so alternatively you could play with [the action-hook which AO hooks into](https://github.com/futtta/autoptimize/blob/master/autoptimize.php#L264-L268),
   where you could INIT earlier by setting the AUTOPTIMIZE_INIT_EARLIER constant
   or change the priority of the action on template_redirect.
 * but that’s about all I can think of, really …
 * frank
 *  Thread Starter [nickmobmethod](https://wordpress.org/support/users/nickmobmethod/)
 * (@nickmobmethod)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/#post-7295363)
 * Changing to [http://dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js](http://dev2.kuponarama.ru/wp-content/themes/mobile/js/search.js)
   doesn’t help.
 * But anyway thanks a lot for your time!
    Good luck, Frank!

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/page/2/?output_format=md)

The topic ‘Cannot optimize mobile theme’ is closed to new replies.

 * ![](https://ps.w.org/autoptimize/assets/icon-256X256.png?rev=2211608)
 * [Autoptimize](https://wordpress.org/plugins/autoptimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autoptimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autoptimize/)
 * [Active Topics](https://wordpress.org/support/plugin/autoptimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autoptimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autoptimize/reviews/)

 * 16 replies
 * 2 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/cannot-optimize-mobile-theme/page/2/#post-7295367)
 * Status: not resolved