#316·idb

Remove Add Event Listeners?

Author: fadi-georgeCreated Jul 3, 2024Updated Dec 16, 2024

Hello, I was looking to using this package in an effort to replace Dexie with a smaller package. When I profiling idb against Dexie and other options, I noticed that it adds way more event listeners than expected.

I made a simple setup here: https://github.com/fadi-george/idb-test

I noticed that with idb, I see a lot of listeners being added. idb-1

And it can be up to 2x the number of listeners compared to Dexie. dexie-2

Basic IndexDB for comparison: basic-1

Which brings me to my point where I copied over the idb src files and changed the event listeners to event handlers. Things like:

request.addEventListener('upgradeneeded', (event) => { ...

being changed into

request.onupgradeneeded = (event) => { ...

And then saw an obvious reduction in the listener count. idb-custom-1

So maybe it would be good to switch all the event listeners to event handlers.