JSON vs big JS array

javascript, json, performance

Solution

You should consider using JSON over AJAX to fetch the data. It will make your page seem like it loads a lot faster. You can then use WebWorkers (if the system supports them) to parse the JSON data in a separate thread. This would be idea.

500kb of JSON likely would not cause any significantly significant parsing overhead, so I wouldn't worry about crashing anyone's browser.

Problem

I am making a jQuery autocomplete and I have something between 10~20k registers. The data is static (i'll run a update script when i need) and I can choose to get the file from a JSON or embed in the page in a single line like: ``` var title = ["example title 1","example title 2"]; ``` Which one should I choose performance wise? (also I am worried about crashing/lagging peoples browser).. And what about XML? BTW my PHP script is already using a cache system for the HTML.

Original source