آخرین اخبار، به‌روزرسانی‌ها و داستان‌های ما برای توسعه‌دهندگان

Display images without causing layout shifts

    ۲۷ فوریهٔ ۲۰۲۵

    Creating placeholders for page content can sometimes be as simple as adding a background effect to existing page elements. In this example, all list items share the same underlying HTML structure. However, the placeholders are styled with a gray

    • CSS
    • HTML
    • جاوا اسکریپت

    ۲۷ فوریهٔ ۲۰۲۵

    Reserve space for future page content

      ۲۷ فوریهٔ ۲۰۲۵

      It is incredibly important to deliver fonts quickly: faster font delivery not only means that text will be visible to the user sooner - but it also has a large impact on whether a font causes layout shifts. If a font cannot be delivered before it is

      • HTML

      ۲۷ فوریهٔ ۲۰۲۵

      Avoid layout shifts when using infinite scroll

        ۲۷ فوریهٔ ۲۰۲۵

        Banners and notices that don't cause layout shifts

          ۲۷ فوریهٔ ۲۰۲۵

          This carousel uses CSS scroll snap to create smooth, performant slide transitions that do not cause layout shifts. This carousel can be navigated in a variety of ways: in addition to navigation controls, it supports keyboard navigation and swiping.

          • HTML
          • جاوا اسکریپت
          • CSS

          ۲۷ فوریهٔ ۲۰۲۵

          Animated GIFs can be 5-20x larger than the equivalent MP4 video. However, MP4 videos can be configured to look and feel like GIFs by including the autoplay loop muted playsinline attributes on the <video> tag. In addition, to prevent layout

          • HTML

          ۲۷ فوریهٔ ۲۰۲۵

          This animated footer slides-in from the bottom of the page. The effect is created by using the CSS transform property. The result is a performant animation that does not cause layout shifts.

          • CSS
          • جاوا اسکریپت
          • HTML

          ۲۷ فوریهٔ ۲۰۲۵

          Performant carousels

            ۲۷ فوریهٔ ۲۰۲۵

            Responsive images are often implemented with the srcset attribute. The srcset attribute is a comma-separated list of image filenames and their width or density descriptors. To prevent layout shifts, set the width and height attributes on <img>

            • HTML

            ۲۷ فوریهٔ ۲۰۲۵

            This infinite scroll implementation is designed to ensure that there are never any layout shifts - regardless of how long it takes the server to respond with new content. One of the most common issues with many infinite scroll implementations is

            • CSS
            • HTML
            • جاوا اسکریپت

            ۲۷ فوریهٔ ۲۰۲۵

            When optimizing video for Core Web Vitals make sure to set the width and height attributes on the <video> tag. Depending on the situation, you may also want to utilize the poster attribute. width and height attributes: To prevent layout shifts,

            • CSS
            • HTML

            ۲۷ فوریهٔ ۲۰۲۵

            Performant Video

              ۲۷ فوریهٔ ۲۰۲۵

              Sticky footers are a popular way of displaying notices. Notices placed in the footer are less likely to obscure page elements like navigation bars, branding, and banner ads. In addition, sticky footers do not cause layout shifts when they are

              • CSS
              • جاوا اسکریپت
              • HTML

              ۲۷ فوریهٔ ۲۰۲۵

              Modals can be used as an alternative to banner notices. Because modals get displayed on top of existing page content, they do not cause layout shifts when they are displayed. This modal grows in size to fit its contents.

              • جاوا اسکریپت
              • HTML
              • CSS

              ۲۷ فوریهٔ ۲۰۲۵

              Load fonts quickly

                ۲۷ فوریهٔ ۲۰۲۵

                Self-hosted fonts are font files that are served from your own servers - rather than those of a third-party font provider (for example, Google Fonts). It is incredibly important to deliver fonts quickly: faster font delivery not only means that text

                • HTML

                ۲۷ فوریهٔ ۲۰۲۵

                Setting the width and height attributes on <img> tags helps prevent layout shifts. This information allows the browser to reserve the correct amount of space for the image. Set the width and height attributes: The values of these attributes

                • HTML

                ۲۷ فوریهٔ ۲۰۲۵