I tested the current version of Mobile Detect https://github.com/serbanghita/Mobile-Detect/ 5.x v.2.8.41 from Nov 23, 2022

I must say that it only looks a huge code to run, but actual detection time is about 0.00350 sec.

It does a pretty awesome job with modern devices, such as Galaxy Fold and detected when a visitor requests `desktop version` of a page in a mobile browser. I used a tip to cache detection result in session and added an md5 of user-agent to separately cache `desktop-mode` requests. This brought the timing to a few microseconds – 0.00009 sec at most.

Screenshot-2022-12-02-034213.668.png
Testing Mobile Detect
Screenshot-2022-12-02-034213.668.png (12.31 KiB) Viewed 14790 times