How much data can a javascript program reasonably expect to handle?
I'm writing some grading software with GWT. I want to handle, you know, a list of students, a list of assignments, and scores for students x assignments. Maybe up to 40x100 assignments, each with a name, a date, a score, etc. And then I'd like 开发者_JS百科to have multiple courses. So, x7.
All of a sudden this is looking like over a megabyte of data. Can browsers handle a megabyte of data easily? When do things start to get sketchy on, say, IE6 on a computer from 2001?
At one stage a commercial GWT application we built had an initial data download running up to 1MB (uncompressed) for some clients. We also have some customers who use our website on IE6 on older machines and also on thin clients. In short: slow but usable. Chrome and other decent browsers will take that sort of payload in their stride, on IE 8 and lower it can be quite painful depending on your specs. Thankfully in my experience the modern IE6 user is fairly well conditioned by now to staring vacantly at the screen while things load, so you won't draw too many complaints if your website is a bit slow.
There is noticeable browser lock-up when the data finishes downloading as GWT deserializes it into javascript objects. If you try to build up an interface for the data the moment you receive it the lock-up can get pretty bad. Pulling out individual records and displaying them is nice and fast no matter how much data you have, as long as you put a bit of thought into your data structures. If you're trying to use it all as a dataset for statistical analysis, well... computing average grades might complete in a second or three, but don't push your luck in terms of complexity.
My advice (i.e. what we did) is to put all your data in a database, and have your GWT application only download the portions that it needs as it needs them. Effective interface design is important. You want to start out showing a list of courses, when the user clicks one display a list of students in the course and display them, when the user clicks a student download their assignments and display them. If you want to display summaries and statistics for a group of assignments do your calculations on the server, preferably with your database's aggregate functions. If that starts to put undue load on your server consider caching the results of common queries.
精彩评论