DEV Community

Discussion on: Search and filter a table with JavaScript

Collapse
 
michelc profile image
Michel

Damn! Under Firefox I didn't see the problem.

A quick solution that may be enough is to load the script asynchronously:

<script src="/scripts/js-table-filter.js" async></script>

(I updated the post.)

If necessary, wait until the DOM is fully loaded before triggering the filter. Something like :

function domReady (callback) {
    if (document.readyState !== "loading")
        callback();
    else
        document.addEventListener("DOMContentLoaded", callback);
};
domReady(TableFilter.init);

Instead of TableFilter.init();.

Good catch! And sorry for the late response.