views:

45

answers:

2

I am running a Facebook application that asks users questions. When they complete one question they move onto another.

What I thought about is when they first hit the application the script pulls 300 questions from the database and loads them into either and array or JSON in Javascript.

In either case (Array or JSON), how many elements would be acceptable as to not make an impact on the users browsing experience?

Would 300 be to many? It's unlikely any user will sit there and answer 100 questions let alone 300 but I'm just making curious.

I'd like to do it this way to save on Ajax requests to the database load a new question.

A: 

JSON is not limited. You can put as many data in JSON array as you wish. Only limits can be for parser or data transfer.

UPDATE: I just found similar question - http://stackoverflow.com/questions/1262376/is-there-a-limit-on-how-much-json-can-hold

Māris Kiseļovs
Hi. I understand their is no limit but if I was to add to much data would is slow the users browser. Would 300 elements be considered to many? Or acceptable.Thanks for the response.
Jamie Redmond
Actually I get it. Storing the data is not really a problem but parsing it could be.
Jamie Redmond
A: 

I don't think the speed of processing the JSON would matter as much as the data transfer to access the 300 questions (since the script is client-side, the client has to load the JSON, and that will initiate another data transfer).

So, 300 questions at 100 bytes each would mean 30 kB of data, which doesn't take very long on broadband. I think you'd have to have a lot more to worry about either data transfer or processing.

But, again, I think the data transfer would take longer than the processing for a modern computer.

However, if trying to tailor this for mobile devices, then 300 questions may be at the limit of acceptable.

palswim