fullcalendar event rendering performance issue

So, basically all my events(there’s min. 360 of them) have team1 vs. team2 or - vs. team2 or team1 vs. - placeholders.
And on the initial render events change color depending on whether the event has one or two teams.
Orange color for the one team , and green for the two teams. Also, the event changes color on click.

But mostly, I’m interested in increasing performance with rendering events.

Rendering performance is going really bad in fullCalendar, and I couldn’t find any solution to this problem.

So here’s my code:

eventRender: function (event, element) {
                $(element).append((event.teams[0] != null ? event.teams[0] : '-') + '</br> vs. </br>' + (event.teams[1] != null ? event.teams[1] : '-'));
                if (event.teams.length === 1) {
                    $(element).css('background', 'orange');
                }
                else if (event.teams.length > 1) {
                    $(element).css('background', 'green');
                }
            }  

My main issue is that when I click on event to change its color, the script automatically goes to the eventRender or eventAfterRender event, and its behavior is exactly like the for statement – it iterates over events and then it does the stuff that I want to do with the individual event, but only when the loop lands on the clicked event.

Also, in the eventClick I’ve called $('#myCalendar').fullcalendar('updateEvent',event) and I think there is a bug, because it automatically goes to the eventAfterRender or the eventRender, iterating over the whole events collection again.

Even tough 'updateEvent' parameter should instruct fullCalendar to update/render only the specific event.

Does anyone have any advice on this subject?

47 thoughts on “fullcalendar event rendering performance issue”

Leave a Comment