Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Frank Goossens

    (@futtta)

    Morgen Harry;
    Had quick look, you’ll have to add jquery.js to the comma-seperated list of JS exclusions and all will (very probably) be fine.

    hope this helps,
    frank

    Thread Starter Harry Milatz

    (@harry-milatz)

    Hi Frank,

    yes it works now, thanks a lot!! But the pagespeed increase now for 14 points for mobile(98->84) and 2 for desktop(96->94).
    Any idea what can i do for the mobile speed?

    In the mobile version(Wptouch) i don’t use the YASR Plugin and here is everything fine if jquery.js is not excluded. Is there any way to exclude it only for desktop, e.g. with user agents?

    Plugin Author Frank Goossens

    (@futtta)

    Hmmm … user agent sniffing is notoriously difficult, but if you insist it should be possible using the API, something like;

    add_filter('autoptimize_filter_js_exclude','harry_ao_override_jsexclude',10,1);
    function harry_ao_override_jsexclude($exclude) {
    	if (strpos($_SERVER['HTTP_USER_AGENT'],'mobile')!==false) {
    		$exclude=str_replace(", jquery.js","",$exclude);
    	}
    	return $exclude;
    }

    Do take into account that this code will likely not work as is, this is entirely untested, but it gives you an idea how you could approach this. The code looks for “mobile” in the useragent (too simplistic, for sure) and if so it will remove “, jquery.js” from the list of exclusions (error-prone as well, as the space might not be there, but that’s under your control).

    But to be honest; I wouldn’t do this. Instead I would try to live with the somewhat lower pagespeed score, or I would try to find another solution for the star rating plugin so I would not have to exclude jquery in the first place.

    good luck! ??
    frank

    Thread Starter Harry Milatz

    (@harry-milatz)

    Hi Frank,

    i wasn’t lazy the last hour;) I am now using jquery 2.0 for the mobile version and it seems there is nearly everything fine. So the speed is really good for mobile and the few points increasing for desktop is not so bad;)

    Try to live with the lower speed was no option:D
    And i didn’t find another good star rating plugin;)

    Thx, i will try your code and yes it gave me an idea;)

    Best regards,
    Harry

    Thread Starter Harry Milatz

    (@harry-milatz)

    So your code is working fine;)

    add_filter('autoptimize_filter_js_exclude','harry_ao_override_jsexclude',10,1);
    function harry_ao_override_jsexclude($exclude) {
    	if (strpos($_SERVER['HTTP_USER_AGENT'],'mobile')!==false || strpos($_SERVER['HTTP_USER_AGENT'],'Mobile')!==false || strpos($_SERVER['HTTP_USER_AGENT'],'Mini')!==false || strpos($_SERVER['HTTP_USER_AGENT'],'Android')!==false || strpos($_SERVER['HTTP_USER_AGENT'],'Google')!==false || strpos($_SERVER['HTTP_USER_AGENT'],'Googlebot')!==false || strpos($_SERVER['HTTP_USER_AGENT'],'Playstation')!==false || strpos($_SERVER['HTTP_USER_AGENT'],'Page')!==false) {
    		$exclude=str_replace(",jquery.js","",$exclude);
    	}
    	return $exclude;
    }
    Plugin Author Frank Goossens

    (@futtta)

    How I *love* my API ??

    you could combine the first two conditions (mobile vs Mobile) with https://php.net/stripos

    and what is the “Page” for?

    Thread Starter Harry Milatz

    (@harry-milatz)

    Yes it’s great;)
    You’re right with stripos

    “Page” is for the Google PageSpeed Insights Test.
    The UA looks like “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.8 (KHTML, like Gecko; Google Page Speed Insights) Chrome/19.0.1084.36 Safari/536.8”

    Thread Starter Harry Milatz

    (@harry-milatz)

    btw i changed the version in “autoptimize_helper.php” to
    Version: 1.9.2
    because the Backend is always telling there is an update;)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Problem with YASR (Yet Another Star Rating) Plugin’ is closed to new replies.