Reputation: 32899
For maximum load speed and page efficiency, is it better to have:
var myname = jsonobj[1]['name']
).var nameidx = titles.getPos('name'); var myname = jsonobj[1][nameidx]
).I'm not really expecting anyone to give me a definitive answer, but a general suspicion would be very useful. Or tips for how to measure - perhaps I can check the trade-off between load speed and efficiency using Developer Tools.
My suspicion is that any extra efficiency from using a native JavaScript object in (1) will be outweighed by the much smaller size of the CSV file, but I would like to know if others think the same.
Upvotes: 3
Views: 6151
Reputation: 8433
What is your situation? Are you writing some intranet site where you know what browser users are using and have something like a reasonable expectation of bandwidth, or is this a public-facing site?
If you have control of what browsers people use, for example because they're your employees, consider taking advantage of client-side caching. If you're trying to convince people to use this data you should probably consider breaking the data up into chunks and serving it via XHR.
If you really need to serve it all at once then:
In other words: it depends. Benchmark it.
Upvotes: 3
Reputation: 700192
That depends a lot on the bandwidth of the connection to the user.
Unless this is only going to be used by people who have a super fast connection to the server, I would say that the best option would be an even smaller file that only contains the actual information that you need to display right away, and then load more data as needed.
Upvotes: 0
Reputation: 123367
14Mb of data are a HUGE difference, but I will try first to serve both the content with GZIP/Deflate
server side compression and, thus, make a comparison of these requests (probably the CSV request will be again better in content length)
Then, I would also try to create some data manipulation tests on jsperf
both with CSV and JSON data with a real test case/common usage
Upvotes: 0
Reputation: 6092
Did you considered delivering the json content using gzip - here is some benchmarks on gzip http://www.cowtowncoder.com/blog/archives/2009/05/entry_263.html
Upvotes: 5
Reputation: 363
4MB vs 18MB? Where problem? Json is just standard format now, csv is maybe same good and ok if you using it. My opinion.
Upvotes: 0