Engr Afaq Ahmad
Engr Afaq Ahmad

Reputation: 27

disable js for mobile view in wordpress

I want to disable extra JavaScript functions for my WordPress website , because speed of my website is very slow for small screens. i did use multiple plugins for cache, image optimization and for minimizing the JavaScript and Css.Even though I compressed all the JavaScript and Css but its still really slow for mobile devices ,Can you refer me some plugin for disabling JavaScript for mobile views in WordPress, if there is no such a plugin i will go with custom coding..Thank you...

Upvotes: 1

Views: 922

Answers (2)

Sanjay
Sanjay

Reputation: 390

Use wordpress wp_is_mobile() function.This may help you.

Upvotes: 2

Sai
Sai

Reputation: 2658

Calculate window.innerWidth and do this

if(window.innerWidth > 767) {// you can mention your own width.
    //Write all your js code  here.
}

Upvotes: 0

Related Questions