OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

how to fix error Does not use passive listeners to improve scrolling performance (Lighthouse Report)

  • Thread starter Thread starter Yohanes Christian
  • Start date Start date
Y

Yohanes Christian

Guest
A recent Lighthouse Report flagged the following issue.

"Does not use passive listeners to improve scrolling performance"

How do I resolve this issue?.

Code:
( function( document, window, undefined ) {
    var form = document.getElementById( 'form-wrapper' ),
    toggle = document.querySelector( '.search-toggle' ),
    close = document.getElementById( 'search-close' ),
    click = 'ontouchstart' in window ? 'touchstart' : 'click';
    toggle.addEventListener( click, toggleSearchForm );
    close.addEventListener( click, closeSearchForm );

    function toggleSearchForm() {
        if ( form.classList.contains( 'is-visible' ) ) {
            closeSearchForm();
        } else {
            form.classList.add( 'is-visible' );
            form.querySelector( '.search-field' ).focus();
        }
    }
    function closeSearchForm() {
        form.classList.remove( 'is-visible' );
    }

    // Press ESC key close search form.
    document.addEventListener( 'keyup', function( event ) {
        if ( 27 === event.keyCode ) {
            closeSearchForm();
        }
    } );

    // Sticky share button for single posts. Applied only for large screens and icon style.
    if ( window.innerWidth >= 1200 && 'undefined' !== typeof StickySidebar ) {
        var adminBarHeight = document.body.classList.contains( 'admin-bar' ) ? 32 : 0,
            sharedaddy = new StickySidebar( '.entry-body .sharedaddy', {
                containerSelector: '.entry-body',
                innerWrapperSelector: '.sd-social-icon',
                topSpacing: adminBarHeight
            } );
    }

} )( document, window );

<p>A recent Lighthouse Report flagged the following issue.</p>
<p>"Does not use passive listeners to improve scrolling performance"</p>
<p>How do I resolve this issue?.</p>
<pre class="lang-js prettyprint-override"><code>( function( document, window, undefined ) {
var form = document.getElementById( 'form-wrapper' ),
toggle = document.querySelector( '.search-toggle' ),
close = document.getElementById( 'search-close' ),
click = 'ontouchstart' in window ? 'touchstart' : 'click';
toggle.addEventListener( click, toggleSearchForm );
close.addEventListener( click, closeSearchForm );

function toggleSearchForm() {
if ( form.classList.contains( 'is-visible' ) ) {
closeSearchForm();
} else {
form.classList.add( 'is-visible' );
form.querySelector( '.search-field' ).focus();
}
}
function closeSearchForm() {
form.classList.remove( 'is-visible' );
}

// Press ESC key close search form.
document.addEventListener( 'keyup', function( event ) {
if ( 27 === event.keyCode ) {
closeSearchForm();
}
} );

// Sticky share button for single posts. Applied only for large screens and icon style.
if ( window.innerWidth >= 1200 && 'undefined' !== typeof StickySidebar ) {
var adminBarHeight = document.body.classList.contains( 'admin-bar' ) ? 32 : 0,
sharedaddy = new StickySidebar( '.entry-body .sharedaddy', {
containerSelector: '.entry-body',
innerWrapperSelector: '.sd-social-icon',
topSpacing: adminBarHeight
} );
}

} )( document, window );
</code></pre>
 

Latest posts

S
Replies
0
Views
1
Souvik Manna
S
S
Replies
0
Views
1
Shelling ford
S
Top