As far as today is September 2016 , I see that jQuery (version 3.1.0) still does not include its own method to get element.clientWidth
and element.clientHeight
normalized way in different browsers.
However, exploring various sources, it turns out that these JavaScript properties are supported in most browsers used today.
On the MDN clientHeight page, I can read that it is supported in Chrome, Firefox (Gecko), Internet Explorer, Opera, Safari (WebKit), but there is no version name.
QuirksMode indicates these properties are supported from IE 9+ and other browsers when applied to window
and document
objects.
Another QuirksMode article on two properties that apply to page elements does not specify browser support specifications, but a very useful page tester is available to check the consistency of element sizes in browsers that you have:
http://www.quirksmode.org/dom/tests/elementdimensions.html
In this article on the clientHeight property , itβs important to focus on the differences between physical pixels and logical pixels in IE <8 and IE> = 8:
In Internet Explorer, earlier than version 8, it extracts height in the size of a physical pixel, whereas from version 8 it returns height in the size of a logical pixel.
Assuming that using zoom in browsers is mainly used on mobile devices, I think that:
- it is safe enough to use
element.clientWidth
and element.clientHeight
for desktop audiences / web applications; - for pages with multiple devices / web applications, using units of a relative unit of measure (e.g. em) can solve the gap between physical and logical pixels.
For easier size management, the em block can improve cross-platform development ( W3 org specifications on units and draft a>), which seems to be supported in modern browsers . I still have no experience regarding units of relative measure in CSS CSS queries, but after reading this interesting article about the best unit measure for CSS media queries , it might be worth exploring.
Any opinion on these considerations is appreciated.