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.– SteveNov 25, 2019 at 6:48
-
1it 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 :/– gaelNov 25, 2019 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 HayesNov 26, 2019 at 1:32
Add a comment
|