-1

I used wordpress, on display mobile I wanna remove some file js by php ? thanks all.

Tobi
  • 39
  • 1
  • 5
  • if you want to load some other js when you are in mobile, give it conditionally using php. This may [help](http://stackoverflow.com/questions/4117555/simplest-way-to-detect-a-mobile-device) – VipindasKS May 05 '16 at 03:46
  • Take a look at the following resources: https://wordpress.org/plugins/wp-mobile-detect/ or https://codex.wordpress.org/Function_Reference/wp_is_mobile. – andreivictor May 05 '16 at 04:44

1 Answers1

0

Need check is page display in mobile.

Like this:

function isMobile()
{ 
    if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
    {
        return true;
    } 

    if (isset ($_SERVER['HTTP_VIA']))
    { 
        return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
    } 

    if (isset ($_SERVER['HTTP_USER_AGENT']))
    {
        $clientkeywords = array ('nokia',
            'sony',
            'ericsson',
            'mot',
            'samsung',
            'htc',
            'sgh',
            'lg',
            'sharp',
            'sie-',
            'philips',
            'panasonic',
            'alcatel',
            'lenovo',
            'iphone',
            'ipod',
            'blackberry',
            'meizu',
            'android',
            'netfront',
            'symbian',
            'ucweb',
            'windowsce',
            'palm',
            'operamini',
            'operamobi',
            'openwave',
            'nexusone',
            'cldc',
            'midp',
            'wap',
            'mobile'
            ); 

        if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
        {
            return true;
        } 
    } 

    if (isset ($_SERVER['HTTP_ACCEPT']))
    { 
        if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
        {
            return true;
        } 
    } 
    return false;
}

Then you can didn't load the js file.

steve
  • 1,150
  • 4
  • 13
  • 24