The onBeforeCellRender implementation must be very fast because it's called for every cell in the grid during scrolling.
I recommend reading all cell data in advance and storing it on the client side. The onBeforeCellRender handler would only read the values from there.
The data can be stored in a global variable, or with resources (if it is resource-specific). See also the following tutorial:
https://code.daypilot.org/93068/javascript-scheduler-displaying-holidays