skip to Main Content

Here is my test html file

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Test</title>
        
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
    </head>
    <body>
        <div x-data="{ open: false }">
            <button @click="open = ! open">Toggle</button>

            <div x-show="open" @click.outside="open = false" style="display: none;">Contents...</div>
        </div>
    </body>
</html>

When I view this content on my mobile via Chrome browser. The button press causes the text to show up immediately.
But if I remove <meta name="viewport" content="width=device-width, initial-scale=1.0">, there is a small but noticeable delay between the button click and the appearance of the text. This delay does not occur on desktop browsers, but only on phones.

2

Answers


  1. When you remove this meta tag, it can affect how the page is rendered on mobile devices. Without the viewport meta tag, the browser may not properly adapt the content to the device’s screen size, which can result in delays in rendering and interactions, especially on mobile devices with different screen sizes and resolutions

    Login or Signup to reply.
  2. This is due to the mobile browsers adding a 300-500ms delay in case there is a double-tap by the user to trigger a zoom. It’s a very old issue that is resolved by adding the <meta name="viewport"> tag. As you have discovered it improves UI performance for the user.

    For many years, mobile browsers applied a 300-350ms delay between touchend and click while they waited to see if this was going to be a double-tap or not, since double-tap was a gesture to zoom into text.

    Read here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search