I’m developing a web application that is entirely in one page and is based on displaying a bunch of table data in grids. There are about 30 different tables in the database, any one of which can be requested by the user to display in a grid on their screen at any time. Most, but not all, of these tables have fewer than 1000 rows. The data for these grids is being called in and loaded via ajax.
Right now, I display the log in screen and immediately preload a few of the main tables, so as the user is typing in their user name and password, it’s loading the initial grids. This has really increased user experience since they don’t have to wait for an ajax call after clicking to see one of these datagrids. As a result, I’m thinking of taking it a step farther.
I am considering making ajax calls to load all 30 tables in the background. They won’t be added to the dom until needed, but instead into an array. The negative is I don’t know if the user will use half these tables in their session, but the ones they do will normally show immediately upon user request and create a better user experience.
So, my questions are, is it a good idea to store 30 full datatables (mostly about 50 to 1000 rows per table) in arrays via ajax calls, and if so, what’s the best way to do it to get the best performance (keep in mind I am just putting them in arrays and not adding them to the dom after preloading)? Which of the following would be the best way:
- Make 30 ajax calls for each table on page load
- Make 1 ajax call on page load that returns all the tables
- Make like 5 ajax calls on page load that each return like 6 tables
- Skew the ajax calls so I make a few and then once they complete, make a few more
- Some other method…
I’d suggest loading the main tables in one call, and then the remaining tables another call. The main issue is that if you batch anything together, none of that information will be available to the application until the entire AJAX request completes. So if you load everything in one call, that may take a while, and the main tables won’t be ready when the user finishes logging in.