My webpage gets laggy after a few hours when using Daypilot(trial) scheduler
10 years ago.
I'm experimenting with the scheduler in my page(angular version). I'm requesting the most recent events from my server every 10 seconds and assign the response to scheduler.events.list. The page gets laggy after about 4-5 hours. Not only daypilot, but the whole page gets laggy.
Here is the function that is executed every 10 seconds:
function loadEvents() {
//Angular $resource factory
EventsService.getEvents({}, function(response) {
var events = response.events;
var now = new Date().getTime();
$scope.currentevent = null;
for(var i = 0; i<events.length && $scope.currentEvent === null; i++){
var value = events[i];
if(new Date(value.start).getTime()<now && new Date(value.end).getTime()>now){
$scope.currentEvent = value;
}
}
//I use daypilot to show the events, the below code only updates the list of events if
//The events have changed
var currentEvents = JSON.stringify($scope.scheduler.events.list);
var newEvents = JSON.stringify(events);
if(currentEvents!=newEvents){
$scope.scheduler.events.list = events;
$scope.scheduler.update();
}
$timeout(function () {
loadEvents();
}, 10000);
});
}
here is my scheduler config:
$scope.schedulerConfig = {
allowEventOverlap: false,
eventResizeHandling: "Disabled",
eventMoveHandling: "Disabled",
visible: true,
scale: "Minute",
cellWidthSpec: "Auto",
tapAndHoldTimeout: 0,
rowMinHeight: 80,
eventHeight: 80,
days: 1,
startDate: new DayPilot.Date().firstDayOfMonth(),
theme: "daypilottheme",
timeHeaders: [
{ groupBy: "Hour", format: "HH:mm" }
],
};
Removing daypilot from my page but keeping the 10 second interval seems to solve the issue. Am I doing something wrong?
DayPilot