LinkedIn Facebook Twitter bemoko blog bemoko technical pages
Tel: +44 1256 581028 Email:

Bemoko blog > January 2013



Responsive Design “delving deeper”

Posted By Emily Nicholls Thursday, January 31, 2013. No Comments

With so much interest in ‘Responsive Web Design’ in 2012, we have delved deeper to see if this is the right approach for Web Development moving forward. For many it offers a low cost approach to a write once web development. However, there are limitations and this article tries to explain these, and how the Responsive Web Design concept can be taken to a more dynamic and vastly improved user experience.

What is it?
Responsive web design is the approach taken to ensure that the website layout adapts to the browsers viewport (the dimensions of the browser window in which the website is displayed, not including the scroll bars and address bars etc).

How is it done?
Responsive Web Design is traditionally made possible through the use of CSS Media Queries, JavaScript can then take this one step further, and can be used to modify the DOM (the structure of the markup)

These allow for a set of CSS styles to be applied when the browser is in a certain condition.

Typical queries are:
• Width & Height@media screen and (min-width: 400px) and (max-width: 700px)
• Orientation@media all and (orientation:portrait) { … }
@media all and (orientation:landscape) { … }
• Aspect Ratio@media screen and (device-aspect-ratio: 16/9) { …

Using javascript it is possible to detect if the browsers screen has changed size by listening for the onresize() event.
When a screen change has been detected, you can make the required DOM modifications to adjust the layout of your content to the new browser view port dimensions.

Problems with this approach
Responsive Web Design works best when used in small edge case scenarios, as it able to deliver rapid layout changes, without the backend heavy-weight that is device knowledge. However, when delivering sites outside of these edge-case scenarios, Responsive Web Design may not be the best approach. Particularly when targeting a wide range of devices and browsers. When using Responsive Design with the traditional methods of CSS and Javascript for this, a few problems are introduced:

Page Weight
With media queries, there is much redundant styling that will never get used by the device under any circumstance. All this redundancy dramatically increases the page weight, which in turn slows the browsing experience of your site down.

While CSS media queries are fast to adapt content upon viewport changes, the actual .css files are fairly hefty as all styling for all eventual layouts are included in the page. So you are potentially increasing the size of your style sheets by a multiple of the number of layouts you are targeting.

Depending on the size of your size, and the amount of DOM manipulation needed, your JavaScript files could also run the same issue as CSS.

CSS can hide/display/resize images, but this does not help with the actual download of the image. If an image has display:none it has still been downloaded by the browser in its original format.

Unexpected onresize() events
When using onResize(), pay caution to the many unexpected events cause the event to trigger. These are the events known to trigger this event:

• User resizes browser window by dragging the corner or edge.
• Users enters full screen or window view of browser.
• The orientation of the device switches from landscape to portrait or vice-versa.
• Modification to the DOM which causes the scroll bar to appear within the browser, in effect reducing the view port.
• When the users scroll down the page, and the address bar is hidden, this increases the size of the view port and hence fires this event.
• User changes the zoom level
• The view port meta changes

Clunky Reloads
A technique that some sites have incorporated is to refresh the page upon a change in viewport. This will reset the users page view progress, and potentially also lose input field information as the page is in effect reloaded.

On smart phones, users tend to browse the site in ‘Portrait’ mode, but when they are then asked to input details in a complex form, they prefer the keyboard display in ‘Landscape’ mode.

Unexpected User Experience
As a user is browsing the site in a ‘Portrait’ mode, and they then switch to a ‘Landscape’ mode, the layout that the user should now see should not be dramatically different. Any adjustments to the navigation may throw the user off, as they will need to readjust their ability to use the site.

Hard to maintain and improve
Having multiple style sheets for all the possible viewport groups that you wish to support which modify the layout of each, as well as handling the JavaScript interactions and DOM manipulations, can become hard to maintain. Especially when a new feature needs to be imposed on the site that requires specific JavaScript function or CSS styles, ensuring that it does not break on other devices remains a challenge.

Many solutions can be derived through client-side javascript that will “pull” content from the server, and manipulate it to display the desired layout. Although possible, this approach has its inherent problems. These mainly boil down to:-

1. Latency The time it takes to pull content via javascript over the mobile network. For example updating images from a 240px initial load, to 980px will result in an increased page load.

2. Re-rendering the user may see the “lowest denominator” version of the site while content is being pulled and manipulated by the browser, resulting in a “Clunky Reload”.

3. Slow UX Javascript intensive pages will slow down the browsing experience, causing lags in scrolling and animations and other navigation elements.
A more practical approach to Responsive Web Design is to integrate the discovery services of device recognition, the processing power of server-side mark-up manipulation and image delivery, and the final tweaking using CSS media queries and JavaScript.

Using these combination methods, here are some suggestions for Responsive Design Practice to help reduce the known issues identified earlier:

Targeted Responsive Design
Using intelligent capability discovery will, through tools such as device databases, will allow developers to deliver content that is known to be supported by the requesting device, such as:
• Only deliver responsive style sheets to devices that support it.
• Only deliver styling that will actually get used by that device (i.e. do not deliver a media query of width > 800px if that device can never achieve that width)
• Only deliver JavaScript to devices that can handle it well.
• Only deliver optimized images for that device.

Scale Up
If relying on responsive design, make sure that your page “scales up” to the highest denominator, instead of “scaling down” a PC based site to fit on a mobile.
This not only reduces page weight, but also ensures that the devices that can support the intensive DOM manipulation and enhanced CSS styling will be using their full capabilities to do so.

Ajax Reload of Selective Content
Instead of reloading the entire window, use AJAX to reload sections of content that are affected by the new viewport. This technique will keep the page weight to a minimum, as content is only loaded when needed.
A great example of this would be to just reload the images when a browser orientation changes from ‘Landscape’ to ‘Portrait’.

Adaptive Personalisation
Users should always be given the option to view you site in Full mode. Some users prefer to pinch and zoom their way around a regular designed for pc website, as they feel that the content is more complete or that they are more comfortable with that navigation technique.
Allowing the user to toggle between the Full site and the responsive site will give that user the freedom. Once their selection has been made, their preference should be saved, and so on subsequent visits, the user will have their preferred view.

Use an onresize() Margin of Error
When using Javascript to adapt the layout of a device based on the onresize() javascript event, build in an margin of error to allow for accidental give and take. A margin of error of 15% should ensure that no DOM modifications are taken when the browser makes slight adjustments to the viewport as described above causing an overuse of DOM manipulation slowing the browsing experience down. Better still, only adapt when the onresize() will cross the threshold between viewport layouts that you have designed.

Integrating a server-sided approach with client-sided responsive design has many benefits over choosing one over the other.

No Compromise
When developing a responsive site, you are taking a conscious decision to exclude devices that are unable to handle CSS media queries, javascript, or even heavy pages. Alternatively, development could follow the approach to design for the lowest common device, and so more advanced devices are suffering from lack of inclusion, rendering their technological abilities void.

Server Side Platforms
Integrating with a server-sided platform, these devices can still be treated equally, providing access to the same content through alternative means of navigation, layouts and styling.

Only delivering mark-up to devices that support it, and also delivering only relevant mark-up, not only reduces page size, but also reduces the risk of browser hangs and crashes. On mobile devices, it is common for websites with large amounts of Javascript and CSS to cause the browser to crash as the complex queries are too much for the browser rendering engine.

Easier to maintain and enhance
Using Bemoko’s hierarchy approach, breaking down your styles and JavaScript into your defined UI groups will make it much easier to know where changes need to be made, and what will be affected when that change has been made.
Through a combination of our deep mobile expertise and unique technology capability we help our clients to become class leaders in mobile.

During testing, specific devices may throw up rendering abnormalities, and implementing work-arounds for these can be done effectively by targeting the specific device. With responsive design, the ‘work-arounds’ are all included in the CSS or JavaScript which gets delivered to all handsets, not just the devices that require it.
As the capabilities of devices improve, and new technologies become available, dropping these into specific UI Groups will instantly enhance the site. These groups can be targeted to ensure that these will work, and will not break existing functionality on older unsupported devices.

Faster page loads
Page weight is comprised of markup, CSS, JavaScript, and images. Therefor it is evident that reducing page weight will increase page load speeds, the most important factor in mobile web development. Consumers losing patience with the slow mobile web and How Loading Time Affects Your Bottom Line do an excellent job on describing how important page loading times are, and how it can affect business.

Standalone, Client-Side Responsive Web Design works best when the site is targeted to a particular browser or device class. For example, if you only want to support iPhone and Android devices, manipulation of layout via media queries and JavaScript will be a sufficient approach. However, when you wish to develop a site that will work across almost any browser (PC, Tablet, Smartphone, Feature phone, etc) a combination of both intelligent server-sided adaptation and client sided responsive tweaking will be best suited to the task.

By Olaf Dunn @olafdunn on twitter

Share and Enjoy:
  • Digg
  • Sphinn
  • Facebook
  • Mixx
  • Google Bookmarks

Posted in: fundraising, mcommerce, mobile, mobile design, mobile search, mobile technology, mobile UX, mobile web, multichannel, responsive design, web optimisation