Here is an example of how you can use CSS to provide all the Device Metrics for you and even be able to react using pure CSS in most cases. You can also use javaScript or jQuery top obtain the metrics to help increase performace.
A Pen by Andrew Donelson on CodePen.