This is an implementation question.
I have an array of tags which I need to get data for each one. Each of the tags do not need to communicate with eachother. I want to get some data and store it somewhere.
Which is faster?
- Ajax inside a for-loop
- outside the for-loop
- for-loop at the server side?
In general, if you need to load a bunch of small data, its better to have one server endpoint that returns the all the data. It’s simpler for the client side and avoids the overhead of many xhrs. If you have 100 tags, do you really want to invoke 100 xhrs to get them all, not to mention coordinate the callbacks for all 100?