4 reasons not to disable zoom in your responsive design

Does your website use a responsive design and did you ever wonder if it is a convention to disable zooming in or out?

After all, you took so much time to get the design just right. Surely, pinch-to-zoom was built for those old monolithic sites, where you had no other way to handle these beasts?

With many websites that I developed in the past, my opinion too was that when they are build responsive and everything is in the right place, the user doesn’t need to zoom and so you can disable it.

I now think I have been wrong. Here are four reasons that you shouldn’t make the same mistake.

1. You cannot know the user’s intention

Is your content problematic, hard to read, your text too small? Or does the user want to zoom in to show your awesome photo to someone across the room? There is no way for you to know.

Maybe someone wants to copy a paragraph of text. Maybe the buttons are large enough, but a particular user still is about to zoom in to better reach it.

If you cannot know that, don’t assume anything. Just disabling zoom capabilities, you would in fact assume that they aren’t needed.

2. Accessibility issues

You want everyone to access your content. People read a lot on screens every single day. Maybe someone wants to lean back to read and just make the text larger. Why shouldn’t they be allowed to zoom in?

There are also people with bad eyesight, you certainly don’t want to hinder them in using your carefully crafted website or reading your content.

3. Never disable device features

It’s never a good idea to disable specific features of a device.

That’s what zooming essentially is. Sure, it might have been invented to use “old” non-responsive sites on smartphones, but who are you to decide what it is used for nowadays? If device makers and browser vendors include this, why bother with the decision to enable or disable it at all?

4. Devices are different

Finally, you don’t know where your website will be displayed. It might be on the same smartphone that you tested it on. It might be on an old Android tablet, the latest iPad, maybe on a gaming console, or on a TV. Locking the zoom capability, you don’t know for sure that on all those present and even future devices, users can access your site.

How do I control zoom with responsive designs?

You control the zooming of the viewport with this meta tag in your HTML’s head section:

<meta name="viewport" content="width=device-width, initial-scale=1">

There’s a bunch of options, but the easiest and most flexible is the above. It tells the browser to use the device-width for your site, and to not scale the site initially.

Finally, make sure your responsive design always fits the viewport and isn’t zoomed in by default or has elements hanging out to the side.

Update uWSGI to the latest version on Ubuntu 12.04 LTS Precise Pangolin

You sure know this problem: You run a stable Ubuntu version and the package you want is slightly older than the one advertised on the project’s site. So what, you install it via apt-get and that’s it. Well sometimes, that might not be the best idea.

The Ubuntu uWSGI package is on version 1.0.3. So when I had some tough problems last week I thought it was best to update from the Ubuntu version to the latest version 1.9.14. Here’s how:

Thankfully, uWSGI can be installed via PIP:

sudo pip install uwsgi

It installs in /usr/local/bin/uwsgi, but the version you probably have uses /usr/bin/uwsgi. No problem, just redo the symlink to the newer uwsig:

sudo ln -fs /usr/local/bin/uwsgi /usr/bin/uwsgi

One more thing: Because the PIP version of uWSGI has python already included, remove any plugins=python lines from your uWSGI config files.

That should be it. Stop all uwsgi processes (check ps aux to see they are really gone) and start again with service uwsgi start. Your system now uses the new uWSGI version while having the uWSGI setup that came with the Ubuntu package.

Query Google Analytics API with a service account in Python

I recently needed to display a visitor counter on a website by some client’s weird demand. Maybe the 90s are coming back. Anyway, I thought it makes sense to query Google Analytics directly, but Google’s API example were not really helping. After some digging around, I finally found a solution. You’ll need oauth2client and google-api-python-client for it to work. Then follow these instructions on Google Developers to create a service account that only has access to the API without the need for a human to request some oauth token. It will give you a private key to work with.

from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
import httplib2

def get_analytics_visitors():
    f = file('privatekey.p12', 'rb')
    key = f.read()
    f.close()
    credentials = SignedJwtAssertionCredentials('[email protected]',
                                                key,
                                                scope='https://www.googleapis.com/auth/analytics.readonly')
    http = httplib2.Http()
    http = credentials.authorize(http)
    service = build('analytics', 'v3', http=http)
    data_query = service.data().ga().get(**{
        'ids': 'ga:YOUR_PROFILE_ID_NOT_UA',
        'metrics': 'ga:visitors',
        'start_date': '2013-01-01',
        'end_date': '2015-01-01'
        })
    feed = data_query.execute()
    return feed['rows'][0][0]