You certainly know that weird feature on your smartphone that blocks your actions during a little delay (350ms) when you tap an item on your screen? Some JS scripts can be implemented to avoid that delay, but often without any side effect… Today, it’s possible to do it with only CSS!

Some explanations

This delay has been added to let your device detect a double-tap on the screen, et to let the guy who taps, the time resquested to tap 🙂

But, sometimes, when that double-tap action is not used by our interface it becomes embarrassing especially when your user is waiting for a real reactivity from your web site or your application, and particularly in the context of JS actions with no need in page reload.

Remove the 350ms delay on iOS

Sorry for this iOS-only tips, but I found nothing for Android a this time.

Since iOS 9.3 (update of the day before this post), it’s possible to remove this delay in two ways, one more accessibility-friendly than the other.

Via the viewport meta

Using a meta-viewport containing a width=device-width or a user-scalable=no, you automagically remove the 350ms delay. Example:

<meta name="viewport" content="width=device-width">

The accessibility issue arrives using user-scalable=no. Void the user of the benefit of a zoom on a website is never a good point. Avoid this value at all costs.

Via the CSS property touch-action: manipulation

That property is a part of the Pointer Events specifications.
Briefly, that CSS property has effect when a tap action is done by the user. Values proposed for that property allow free interpretation by the OS, or more restrictive ones depending on which one you choose.

a {
	touch-action: manipulation;
}

The manipulation value define that the tap action made by the user exists only to make the page scroll or to zoom on it. Other actions whom could be defined by the auto value won’t be done.

It’s a blurry definition, than OS are free to make various actions depending on elements and depending on its own features.

On a button or anchor element, or on a trigger defined with JS, the 350ms delay is now removed. It’s already working on this blog, try it by clicking on menu or sidebar buttons. They are super reactive.

I hope this tips will help you 😉

Cet article est également disponible en : French