There is CSS media query for exactly your use-case. No need for sniffing, round-trips or any server-side activity at all.
also, a media query or any other client side method prevents me from delivering exactly the final content that's necessary and not have to do additional reflow-inducing js to get the end result.