Too much initialisation happens before 'beforeInit' hook is triggered

Tags: #<Tag:0x00007efc6d69d050>

Hello,

Recently, I was working on tweaking performance for some of our grids and I needed to access and modify handsontable instance to achieve my goals. Naturally, I turned to ‘beforeInit’ hook but after looking at the profiler output, I realised that there is a bunch of code that gets executed before my callback is reached (If need be, I can elaborate more, but suffice it to say that there is already a large number of handlers assigned to beforeInit, and I need a way to execute my code before they run).

The workaround that I ended up using is to instantiate Handsontable.Core directly and then do my tweaks before calling instance.init() myself (see screenshot of the original Handsontable constructor below for reference), but that is a non-standard way to instantiate handsontable and I would like to request a (hook, callback?) that is officially sanctioned and documented to achieve the same result.

Thanks in advance,
Sandi

1 Like

Hi @shrvic

There is one opened issue related to the beforeInit() hook and its place in the queue of scripts here https://github.com/handsontable/handsontable/issues/5933
I will update you as soon as we get any changes in that matter.

Hey Aleksandra,

The issue you linked is unrelated. That issue complains about hook not firing if it is not added globally, which, if you think about it, makes sense because local handlers are attached after beforeInit fired.
My problem is that other (internal) beforeInit handlers are triggered before my code.

Thanks again,
Sandi

Thank you for the prompt update, @shrvic
I will discuss the subject with my colleagues.

Awesome, thanks again!