I have site which is completely driven by ajax. When an user goes to some category page I want to show products there. What's the best way to fetch products for that category? I have 2 options:
save all products into js variable threw php at first load of website, then when the user goes to some category filter this array to get only those products which has this category and send them to view
dont save all produts into variable in the beggining, but fetch them threw api when an user touch some category
I think first option will be better because all products will be loaded in the begginging and then if an user touch 50 categories, I will not have to send 50 requests for products. But I'm not sure(maybe potencial problem if I have big amount of products)
Thanks.