jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.2k stars 348 forks source link

Remove Add Event Listeners? #316

Open fadi-george opened 4 days ago

fadi-george commented 4 days ago

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.