duerzd696
duerzd696

Reputation: 334

How to remove unload listeners from jquery 3.5.1

After running lighthouse audit on my site - I see there are unload listeners in jQuery 3.5.1. I tried to replace unload/onunload with pagehide/onpagehide event - but lighthouse points to somewhere different in file? There don't seem to be an easy fix for this - does anyone now how to fix?

Here is the jQuery where unload is(repaced unload with pagehide, and onunload with onpagehide):

setDocument = Sizzle.setDocument = function( node ) {
    var hasCompare, subWindow,
        doc = node ? node.ownerDocument || node : preferredDoc;

    // Return early if doc is invalid or already selected
    // Support: IE 11+, Edge 17 - 18+
    // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
    // two documents; shallow comparisons work.
    // eslint-disable-next-line eqeqeq
    if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
        return document;
    }

    // Update global variables
    document = doc;
    docElem = document.documentElement;
    documentIsHTML = !isXML( document );

    // Support: IE 9 - 11+, Edge 12 - 18+
    // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
    // Support: IE 11+, Edge 17 - 18+
    // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
    // two documents; shallow comparisons work.
    // eslint-disable-next-line eqeqeq
    if ( preferredDoc != document &&
        ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {

        // Support: IE 11, Edge
        if ( subWindow.addEventListener ) {
            subWindow.addEventListener( "unload", unloadHandler, false );

        // Support: IE 9 - 10 only
        } else if ( subWindow.attachEvent ) {
            subWindow.attachEvent( "onunload", unloadHandler );
        }
    }
enter code here

Upvotes: 1

Views: 404

Answers (0)

Related Questions