If the array did not change in any way during the life of the page, I would spit out the array exactly as you suggest in your code snippet. There is no real benefit of having an extra ajax call because the size of the array, which I assume, will not be so huge as to affect the initial page load time.
If you browse the pages and do the source view, they do this all the time.
If the amount of data is huge and perhaps adds seven or more seconds to the page load time, I would consider calling ajax. At the very least, the page is rendered, and the user has something to see, meanwhile you may have an image with a tiber with a status message, loading or something else.
I would also say that I see a lot of unnecessary ajax, just for the sake of it. Itβs like premature optimization, people add complexity to solve a problem that they donβt have. Start with a simple how you do if you have problems with the answer on the road with the specified page, and then consider what benefits ajax will bring to the table.
source share