'Laravel - Fullcalendar Loading Speed Issue for 2K+ events
I am using Fullcalendar for my app and i'm having trouble displaying the necessary events for display on calendar.
I display calendar as below;
$calendar = new Calendar();
$calendar
->setOptions([
'plugins' => ['window.interaction', 'window.dayGridPlugin', 'window.timeGridPlugin', 'window.listPlugin'],
'locales' => 'window.allLocales',
'locale' => config('app.locale'),
'events' => [
'url' => route('project_eventsJSON', ['project' => $project]),
],
'firstDay' => 1,
'timeZone' => 'local',
'displayEventTime' => true,
'selectable' => true,
//'initialView' => 'timeGridWeek',
'headerToolbar' => [
'left' => 'prev,next today',
'center' => 'title',
'right' => 'dayGridMonth,timeGridWeek,timeGridDay'
],
]);
$calendar->setId('1');
$calendar->setEs6();
return $calendar;
and my events route as below;
public function CaleventsJSON(Project $project) {
$events = [];
foreach ($req->planneddates as $date) {
$event = [
'id' => 1,
'title' => $name,
'start' => $fullparsed,
'end' => $fullparsed,
'allDay' => true,
];
$events[] = $event;
}
return response()->json($events);
}
Number of events is now more than 2K, i end up with crazy loading times... it takes almost 20 seconds until the events show up on calendar.
I see from my devtools that my events route(shown above) is being called as below;
EventsJSON?start=2022-01-31T00%3A00%3A00%2B03%3A00&end=2022-03-14T00%3A00%3A00%2B03%3A00
start and end dates have no effect, route still loads events from 2 years ago... i dont think i am using this correctly... how could i optimize it so that i am not loading all events and just load the events needed for display?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
