I am using the FullCalendar plug in to provide a calendar to the users of my web application. Within FullCalendar, I am allowing the user to pick between the following views:
right: 'agendaWeek,agendaDay,basicWeek,month'
My problem applies currently only when accessing the month
view. On a busy month, the amount of JSON being return comes up to 5 MB 700KB.
eventSources: [
{
url: 'calendar.php',
type: 'POST',
data: {
emp_id: emp_id
},
}
]
The fetching of this large chunk of data isn't an issue- it doesn't take longer than 1.5 seconds 1 second.
It is the rendering that is problematic- it can take upwards of 10 seconds during which the UI is blocked and the page appears unresponsive (for obvious reasons- the single threaded nature of JS).
I then looked in to Web Workers as a potential solution (I am okay with solutions that work only in newer browsers). However, that is not a simple fix either because any use of Web Workers is probably best done at the plugin (FullCalendar) level as opposed to when I create a calendar instance.
I have also looked at this answer. My evaluation of the suggested solutions:
- Break up the server response into multiple requests: probably doesn't apply here- this is the
monthly
view and users need to be able to see all the events in a given month. - Break up the parsing into multiple pieces: probably best done at the FullCalendar level?
- Send the response off to a web worker and parse it in a web worker (doesn't work in older browsers).
I realize that parsing a large amount of JSON data and rendering it is time consuming. However, what I'd like to be able to do at the very least is to have the rest of the page responsive while events are rendered.
What are some reasonable ways of remedying the situation?
Edit
I completely overlooked the fact that I wasn't filtering the events I needed at the SQL level. I am doing so now and the data coming in is about 700kb as opposed to 5mb. However, the page is still not as responsive at it should be.