I’m currently using CSS media queries to hide things via display:none;
for desktop and mobile. While this works fine for minor things I have a dashboard that has a large amount of functionality depending on the device.
At the moment using display:none
means that the functions still fire and this puts huge strain on our hosting environment. It’s currently taking 16s to load!
Is there an alternate way to only serve the content depending on the device? This way I can stop the desktop functions firing on mobile and vice versa.
Ideally a way of doing it in PHP would be ideal.
Advertisement
Answer
I’ve tried:
<?php if ( wp_is_mobile() ) { ?>
This works really well as it stops ALL the functions firing and I can control whether the desktop of mobile function should fire.