Lessons

Removing lazy loading

Delayed loading is a great technology. Her task is to speed up the site. This is done by downloading images as they become visible to the user.

Refrain from it in the following cases:

  • When loading images located on the first screen. If the image is visible on the first screen, it is better to download it as early as possible. So, the page will load visually faster and the user will start exploring the content earlier, even if the download of the remaining files is in progress.
  • When loading small images. These images are used as icons in the interface. It is better to place them directly in CSS or HTML code as a base64 string.

An example of how enabling delayed loading delays the display of images located on the first screen.

Demonstration
PHP code
HTML code
<?php
$mode = $_GET['mode'] ?? '';
?><!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            .product img {
                max-width:100%;
            }
            .product {
                position: relative;
            }
            .product .time {
                position: absolute;
                left: 5px;
                top: 5px;
                background-color: #fff;
                padding: 1px 4px;
            }
            .btn {
                color: #000;
                text-decoration: none;
                padding: 5px 10px;
                border: 1px solid #000;
                border-radius: 5px;
            }
            .btn:hover {
                background-color: #ddd;
            }
            .btn.active {
                background-color: #000;
                color: #fff;
            }

        </style>
        <script>
            // Функция, которая добавляет на изображение время окончания загрузки
            function endLoading(el) {
                var time = performance.now()/1000;
                el.parentNode.insertAdjacentHTML("beforeend", '<div class="time">'+time+' с</div>');
            }
        </script>
    </head>
    <body style="font-family: sans-serif;">
        Режим: <a class="btn <?=$mode === '' ? 'active' : ''?>" href="./lazyload_remove.php">Отключённая отложенная загрузка</a> <a class="btn <?=$mode === 'enable' ? 'active' : ''?>" href="./lazyload_remove.php?mode=enable">Включённая отложенная загрузка</a>
        <p>Обратите внимание на разницу во времени загрузки изображения.</p>
        <div class="product">
            <img src="./photo.jpg?t=<?=microtime(true)?>" <?=$mode === 'enable' ? 'loading="lazy"' : ''?> onload="endLoading(this)" />
        </div>
        <?php for($i = 0; $i < 100;++$i) { ?>
        <script src="./10-kb-js.js?t=<?=microtime(true).'.'.$i?>"/></script>
        <?php } ?>
    </body>
</html>
<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style>
            .product img {
                max-width:100%;
            }
            .product {
                position: relative;
            }
            .product .time {
                position: absolute;
                left: 5px;
                top: 5px;
                background-color: #fff;
                padding: 1px 4px;
            }
            .btn {
                color: #000;
                text-decoration: none;
                padding: 5px 10px;
                border: 1px solid #000;
                border-radius: 5px;
            }
            .btn:hover {
                background-color: #ddd;
            }
            .btn.active {
                background-color: #000;
                color: #fff;
            }

        </style>
        <script>
            // Функция, которая добавляет на изображение время окончания загрузки
            function endLoading(el) {
                var time = performance.now()/1000;
                el.parentNode.insertAdjacentHTML("beforeend", '<div class="time">'+time+' с</div>');
            }
        </script>
    </head>
    <body style="font-family: sans-serif;">
        Режим: <a class="btn active" href="./lazyload_remove.php">Отключённая отложенная загрузка</a> <a class="btn " href="./lazyload_remove.php?mode=enable">Включённая отложенная загрузка</a>
        <p>Обратите внимание на разницу во времени загрузки изображения.</p>
        <div class="product">
            <img src="./photo.jpg?t=1770055133.5188"  onload="endLoading(this)" />
        </div>
                <script src="./10-kb-js.js?t=1770055133.5188.0"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.1"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.2"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.3"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.4"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.5"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.6"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.7"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.8"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.9"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.10"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.11"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.12"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.13"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.14"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.15"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.16"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.17"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.18"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.19"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.20"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.21"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.22"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.23"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.24"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.25"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.26"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.27"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.28"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.29"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.30"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.31"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.32"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.33"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.34"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.35"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.36"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.37"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.38"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.39"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.40"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.41"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.42"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.43"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.44"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.45"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.46"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.47"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.48"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.49"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.50"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.51"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.52"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.53"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.54"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.55"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.56"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.57"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.58"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.59"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.60"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.61"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.62"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.63"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.64"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.65"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.66"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.67"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.68"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.69"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.70"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.71"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.72"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.73"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.74"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.75"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.76"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.77"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.78"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.79"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.80"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.81"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.82"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.83"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.84"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.85"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.86"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.87"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.88"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.89"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.90"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.91"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.92"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.93"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.94"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.95"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.96"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.97"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.98"/></script>
                <script src="./10-kb-js.js?t=1770055133.5188.99"/></script>
            </body>
</html>

PRO subscription for working with the service

Promo
To prepare a commercial offer.
190 ₽
50 pages for 10 days
  • 1 page gives 1 tool launch Checking the page.
  • Purchased for a specific site
  • Restrictions on other tools remain the same
PRO subscription
For regular work on a site or a group of sites.
1 580 ₽
3,500 pages per week. The subscription period is 1 month.
Wallet
A separate page balance that complements the PRO subscription balance.
190 ₽
Number of pages
  • An active PRO subscription is required to use the wallet balance
We use cookies. By continuing to use the site, you agree to the processing of personal data in accordance with privacy policy. I agree