PHP code example of akh / bitrix-optimization

1. Go to this page and download the library: Download akh/bitrix-optimization library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

akh / bitrix-optimization example snippets


\Akh\BitrixOptimization\Image::initEvents($option = []);

$option = [
    'debug' => false,
    'lazy_addJs' => false,
    'lazy_addJsBgSupport' => false,
    'lazy_active' => true,
    'lazy_background' => false,
    'lazy_dummy' => 'gif',
    'lazy_exclusions' => [
        'lazyload',
        'skip-lazy',
        'data-no-lazy',
        'data-src',
        'data-srcset',
        'data:image/',
        'data-lazyload',
        'swiper-lazy'
    ],
    'webp_active' => true,
    'webp_exclusions' => [
        'skip-webp'
    ],
    'webp_checkHref' => false,
    'webp_checkHrefExclusions' => [
        '#',
        '.css',
        '.js',
        '.html',
        '.svg',
        '.php',
        'mailto:',
        'tel:',
        'javascript:',
        'http://',
        'https://',
        '.ico',
    ],
    'webp_support' => [
        IMAGETYPE_JPEG,
        IMAGETYPE_PNG
    ],
    'webp_folder' => '/upload/webp'
];

\Akh\BitrixOptimization\LazyContent::$loadOnScroll = false
);