Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php/jquery - web development: mobile devices

i'm having a finished website and need to optimize it for mobile devices (ipad/iphone/smartphones ..). what's the best way to detect which mobile device/browser is used? (eg. by jquery-plugin) thanks

like image 718
Fuxi Avatar asked Dec 31 '25 20:12

Fuxi


1 Answers

JavaScript/jQuery is not the best way at all; apart from iPhones etc remember there are also Nokias, and other non-smart phones, which may or may not run JavaScript at all, and if they do, it won't be particularly quickly. Attempting to reconfigure your site using JavaScript on a phone over a few years old is pretty much just going to freeze the phone for at least a second or two whenever a page loads.

I would strongly suggest you look into doing this on the server side as much as possible - even if it's as simple as just swapping the stylesheet. At the basic level you can check the User-Agent header sent by the browser and work it out from there. In PHP, use the get_browser function.

like image 184
Jon Grant Avatar answered Jan 02 '26 11:01

Jon Grant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!