2

Let's say you're displaying a list of products and you can filter the products by different attributes. The filtering is purely front end. Is it recommended to put all the products in the HTML and use styling to show specific ones by filter, or dynamically add/remove HTML elements in the DOM? I'm leaning towards putting it all in HTML and filtering with CSS because the heavy part, loading images, can be deferred.

  • Filtering with CSS? This sounds more like a job for a database and some programming in PHP or similar. – Steve Nov 25 '19 at 6:48
  • 1
    it also depends on your final goal. For SEO purpose, it's good practice to have a single url per filter combination. Moreover, loading All the HTML will slow your page even if you are not loading image and especially if you have a lot of products. So as pointed by @Steve, I would also recommend database and programming :/ – gael Nov 25 '19 at 7:53
  • I want to avoid refreshing the page and the number of products isn't enormous, so that's why I was considering filtering on the front end. I did not think about URL filter combinations, that's a great idea. I'll test out the client-database method, if the delay isn't too bad that definitely sounds like the way to go. Thanks for the help. – Chris Hayes Nov 26 '19 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.