diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index b4e6f0963..8a1ff18e7 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -743,7 +743,12 @@ function nullWorldInfo() { function displayWorldEntries(name, data, navigation = navigation_option.none) { updateEditor = (navigation) => displayWorldEntries(name, data, navigation); - $('#world_popup_entries_list').empty().show(); + const worldEntriesList = $('#world_popup_entries_list'); + + // We save costly performance by removing all events before emptying. Because we know there are no relevant event handlers reacting on removing elements + // This prevents jQuery from actually going through all registered events on the controls for each entry when removing it + worldEntriesList.find('*').off(); + worldEntriesList.empty().show(); if (!data || !('entries' in data)) { $('#world_popup_new').off('click').on('click', nullWorldInfo); @@ -751,7 +756,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) { $('#world_popup_export').off('click').on('click', nullWorldInfo); $('#world_popup_delete').off('click').on('click', nullWorldInfo); $('#world_duplicate').off('click').on('click', nullWorldInfo); - $('#world_popup_entries_list').hide(); + worldEntriesList.hide(); $('#world_info_pagination').html(''); return; } @@ -794,7 +799,11 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) { formatNavigator: PAGINATION_TEMPLATE, showNavigator: true, callback: function (/** @type {object[]} */ page) { - $('#world_popup_entries_list').empty(); + // We save costly performance by removing all events before emptying. Because we know there are no relevant event handlers reacting on removing elements + // This prevents jQuery from actually going through all registered events on the controls for each entry when removing it + worldEntriesList.find('*').off(); + worldEntriesList.empty(); + const keywordHeaders = `