LSS-Manager / LSSM-V.4

The Official Repository for LSS Manager V4
https://lss-manager.de
Other
54 stars 91 forks source link

[Refactor] replace `querySelector` with `getElementById` where possible, cache `querySelector` calls where posssible and needed #3046

Open jxn-30 opened 1 month ago

jxn-30 commented 1 month ago

DOM-Operations and querySelector are heavy operations. getElementById is much faster than querySelector('#id'), especially if called often (e.g. in loops and intervals). If multiple operations need to be done on an element, avoid selecting the element multiple times but cache it (store it in a variable or in an object) instead.

ESLint Rule unicorn/prefer-query-selector needs to be explicitely be disabled therefore.

An ESLint Rule enforcing us to prefer getElementById wherever possible would be good!