0

I am researching the use of adaptive approach vs. reactive approach and in the process have been reading at all the discussions on media query, css width, screen width, window width, document width, etc. There is no single document that I found that addresses all these parameters headon in one place and explore their possible interrelationships in building adaptive or responsive sites.

Here are some of my questions which are not fully explained elsewhere in the totality of the context described above. I have come to some conclusion and want clarification if the conclusions are wrong. I did implement a prototype but it appears to work fine using many approaches. I want to know what are the BEST PRACTICES for implementing adaptive or reactive sites.

Assumption:

a. Wide audience with different desktops and devices but using modern browsers.

b. JS-based solution preferred over pure-CSS.

c. Only focused on screen displays.

RESEARCH (Really, there is not much to it!):

//The traditional way to get widths (using Jquery):
windowWidth    = $(window).width();    // returns width of browser viewport
documentWidth  = $(document).width();  // returns width of HTML document
screenWidth    = screen.width;         // screen width  - Physical screen width


//This is post CSS3 approach to handling width
mql = window.matchMedia('screen and (min-width:500px) and (max-width:800px)');
//Check if there was a match:
if (mql.matches) {  //serve your customized page }
//And then there is the listener that can be added to the object returned 
//by the above query, as in for state changes when the browser is resized.  
mql.addListener(someListener); //Fired only if the match state changes

Most plugins supposedly simplifying the media query API really center on the above API only (e.g. enquire.js). And yes there is device-width which I have not seen used anywhere other than specifying the pixel scale factor in the meta tag. There are many posts questioning why some of the above width parameters, retrieved through media query or through the older approach, do not match. Here is one such post. I understand that.

Now, my questions are:

  1. In all this media query hoopla and the thousands of articles written on adaptive/responsive sites, all we are concerned with is serving content based upon the current browser width and response to browser width changes? Even portrait/landscape is really a width issue.
  2. Is it correct that actual device detection is not targeted by media queries and is not really necessary for developing adaptive/reactive sites? That the sole goal of media queries (for screens) is to compartmentalize browser widths into buckets or breakpoints (See breakpoint.js, for example)?
  3. For developing responsive/adaptive sites to a wide audience, is it worthwhile to use device-detection services such as deviceAtlas?
  4. What real advantages are we getting by using media query API vs. just getting $(window).width? Is it wider browser support? Standard approach? Other advantages? Does not matter which approach you take?
  5. Are most adaptive/responsive sites totally blind to the actual underlying physical device used by the user and rely solely on USER AGENT info and the widths discussed here?
Community
  • 1
  • 1
Sunny
  • 9,245
  • 10
  • 49
  • 79
  • 2
    Though this comment may not answer all of your questions, it should answer a few... The reason why alot of developers use Media Query API over pure javascript, is because the Media Query API is much easier to use over a javascript solution. Technically, Javascript is a better solution, why?, because it has an almost FULL browser support. Even within the dungeons of Internet Explorer, the javascript will work. So all in all, its a small sacrifice of browser support for easier coding. – HTMLNoob Jan 29 '16 at 06:51
  • Also, this question is EXTREMELY opinion-based. I probably should of taken that into note before I wrote the first comment – HTMLNoob Jan 29 '16 at 06:56
  • 1
    not device-width et al https://developer.mozilla.org/en-US/docs/Web/CSS/@media – Carol McKay Jan 29 '16 at 07:35
  • @HTMLNoob, it is really not an opinion-based question. Whether to use JS or pure CSS, for example, is not a question of opinion but there are technical merits and issues around it. There are a whole lot of articles written on the subject of responsive websites but there is none that I came across that discusses the pros and cons, from a technical perspective, of using the various approaches/parameters. I believe that this post will help MANY if answers are precise and on point. My question is not intended to seek any opinions, but precise technical justification for choices. – Sunny Jan 29 '16 at 07:38
  • @CarolMcKay I did reference device width in my post. I have not see it used in any of the articles on the subject other than in the meta tag for pixel/initial-scale ratio. That is really what I am wondering... so much noise on media query but just two or three dimensions/params seem to be heavily used. – Sunny Jan 29 '16 at 07:45

0 Answers0