Lightweight PHP Class for Detecting Mobile Devices
Today I came across a fantastic, lightweight PHP class for detecting mobile devices. It’s called Mobile Detect, and you can download it here: http://mobiledetect.net/
The use case from today involved swapping in a lighter-weight slider element on mobile, while allowing a heavier-weight slider to render on desktop.
Media queries and “display: none;” aren’t sufficient for this, because you’d wind up loading two sliders (whether on desktop or mobile).
Since the heavier-weight video slider in my client’s case is 40MB+, this would be a huge impact on data for mobile users and completely unacceptable.
Mobile Detect also allows you to target tablets, and is currently in beta for detecting browsers (i.e., iOS, Chrome, etc.).
Hats off to Şerban Ghiţă, Nick Ilyin, and Victor Stanciu for developing and authoring this easy-to-use PHP class.