3 ms·
Anna’s Update: fully open source archive, Elasticsearch, 300GB+ of book covers
- Vt71fcAqt7 4y ago>Since we haven’t implemented pagination yet, we would often return very long search pages, with 100-200 results. We didn’t want to cut off the search results too soon, but this did mean that it would slow down some devices. For this, we implemented a little trick: we wrapped most search results in HTML comments (<!-- -->), and then wrote a little Javascript that would detect when a result should become visible, at which moment we would unwrap the comment >[...] >if (topByElement[element.id] <= bottomEdge) { element.classList.remove("js-scroll-hidden"); element.innerHTML = element.innerHTML.replace('<' + '!--', '').replace('-' + '->', '') } If we were already adding classes to the element, surely adding a simple `hidden` element that we could remove would be better?
- JeremyBanks 4y ago[dead]
- zozbot234 4y agoBy leveraging the element.innerHTML they do what they need using a single operation on the DOM, everything else is handled by the browser's optimized parsing and rendering code. It's quite clever actually, makes me wonder if it's been done before.