Don’t load scripts if on mobile/tablet

wp_is_mobile() does not really solve your problem completely. To be honest here, there is no logic in WordPress to achieve what you want

  • First of all, wp_is_mobile() only checks for mobile devices. Tablets are excluded from this

  • Window sizes are determined on browser side, not server side, so there are no way for php to check window size. That is why there are also no function in WordPress that can detect a window size

The only probable way to do this is to make use of javascript. I’ve seen examples where javascript is used to determine window size and then do load something accordingly. I haven’t tested anything like this yet, and frankly, that would also be off topic here. I would suggest that you try a few google searches and testing out a few solutions as I suggested

Leave a Comment