Javascript Causing High CPU Usage
-
Events-manager.js is causing high CPU usage under certain circumstances. As near as I can tell, this is what causes it. All testing was done on WP 6.2.1, EM 6.3, default Twenty Twenty-Three and no other plugins active:
I’m rendering a small calendar (.size-small) above the events list by calling EM_Calendar::output() with ‘calendar_size’ => ‘small’ as one of the arguments. When I do that, cpu usage on that browser tab in both Firefox and Chrome goes up to 25%-45%. Chrome also starts repeatedly displaying a notice in the console “[Violation] Forced reflow while executing JavaScript took ms” approximately every 100ms.
Blocking the load of events-manager.js brings the cpu usage back to normal. So does removing the .size-small class from the calendar in developer tools. So does changing Event Preview Mode from Modal Popup to Tooltip or None in Settings->Formatting->Calendar->Preview Formats.
Adding back the .size-small class on the .em-calendar div in developer tools will trigger the high cpu usage.
It seems like the small calendar has to be on the same page as the events list for this to happen. The high cpu usage doesn’t occur on a page with only the small calendar.
Hope that’s enough information.
The topic ‘Javascript Causing High CPU Usage’ is closed to new replies.