• Resolved robwatsondz

    (@robwatsondz)


    GTMetrix reports recommend that unload not be used for /wp-content/plugins/directorist/assets/vendor-js/openstreet-map/openlayers/OpenLayers.js?ver=5.9.3

    It says:

    Avoid Unload Event Listeners

    • The unload event does not fire reliably and listening for it can prevent browser optimizations like the Back-Forward Cache. Use pagehide or visibilitychange events instead.

    Since we’re not using maps at all on this site, is there a way to completely disable OpenStreetMaps such that the script is not called or loaded at all?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @robwatsondz,

    Thanks for letting us know about this. We plan to bring some optimization for better scores on sites like GTMetrix, this will definitely help.

    To get rid of OpenStreetMap Scripts, if you can get your hand on the code, you can just get rid of the script enqueue for it, scripts for OpenStreetMap get enqueued from the line #254 on /includes/classes/class-enqueue-assets.php, you can get rid of those blocks and you should be good to go.

    Regards,
    Mahdi.

    Thread Starter robwatsondz

    (@robwatsondz)

    Thanks. I hesitate to alter the plugin code in case I break something. Also, if I alter the plugin code now, when the next update happens I’ll lose the changes I made. Unless there’s a reliable way you can think of to dequeue it via the functions.php of my custom theme, I’ll just wait until you have implemented better optimization including this issue.

    Thread Starter robwatsondz

    (@robwatsondz)

    I attempted to do the following:

    // dequeue OpenStreet layers from Directorist plugin as we're not using maps
    add_action( 'init', function () {
        wp_dequeue_script( 'directorist-openstreet-layers' );
    } );

    but apparently that’s not the proper handle for dequeueing this script.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘OpenStreetMaps: Avoid Unload Event Listeners’ is closed to new replies.