0

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
duerzd696
  • 304
  • 1
  • 8
  • A bit of code to reproduce would be absolutely great. Where did you start; what did you change and what are the errors you are receiving. – Marco Apr 03 '23 at 15:12
  • I replaced unload with pagehide, and onunload with onpagehide – duerzd696 Apr 03 '23 at 15:19
  • Perhaps add a set of working code in a snippet with what you are actually attempting since changing the jQuery code code is nearly always/most often not needed when the requirement is clearly understood. Keep in mind you might be able to use a version that does not need to support IE since IE is dead/no longer supported by Microsoft - that removal for you could be a fair bit of work to do just for this challenge. – Mark Schultheiss Apr 03 '23 at 15:33

0 Answers0