Skip to content

vue-doctor/performance/js-cache-storage ​

Cache localStorage.getItem() result in a variable to avoid redundant reads

PropertyValue
CategoryPerformance
Default Severitywarning
Confidencemedium
FixableNo
Engineoxlint
Sincev1.0.0
Frameworksvue, nuxt
Test filesNot checked (which files)

Why it matters ​

Cache localStorage.getItem() result in a variable to avoid redundant reads

How to fix ​

Review the finding and update the code according to best practices below.

Agent Guidance ​

Read localStorage/sessionStorage once into a local variable and reuse it; storage access is synchronous and slow.


Rule source: vue-doctor/performance/js-cache-storage

Released under the MIT License.