This question may have been asked before, but I couldn’t find an answer to it using both Google and the built-in search function of this site.
I want to use jQuery on my website, but only if it is displayed on a desktop computer. If my site is displayed on a mobile device, I don’t want it to load jQuery.
What’s the best way to do this?
Should I use Javascript or PHP for detecting the device type?
http://jsfiddle.net/fk9kC/
The code above is pretty much self-explanatory – by using a DOM element being hidden or shown depending by a screen width you’re being able to target mobile phones more or less accurately.
Furthermore, you can also replace the device-width statement with max-device-width.