January 04, 2021
Filter static list by “using” the gpu :) The three downsides to this are:
display: none;
<!-- This will serve as a list filter --><style id="filter"></style><!-- Type the search term here --><input id="search" type="search" /><ul><li data-value="xyz"></li><!-- the rest of the list items --></ul><script type="text/javascript">// Grab the style tagconst filter = document.querySelector('#filter')// Grab the input controlconst input = document.querySelector('#search')// Make style template to update laterconst style = term => `li:not([data-value*="${term}"]) { display: none; }`// Do the filtering on every inputinput.addEventListener('input',e => (filter.innerText = style(e.target.value)),false)</script>
Written by Milan Miljkovic — a tech enthusiast and design system practitioner.