yoshuawuyts / microcomponent

Smol event based component library
MIT License
35 stars 11 forks source link

Reading of localStorage due to logging #23

Open dchest opened 7 years ago

dchest commented 7 years ago

Since microcomponent uses nanologger, it tries reading from localStorage each time it's initialized. This may have a negative impact on web page loading performance. Also, the logging level will always be info in Safari's private mode, because Safari prevents writing to localStorage by throwing QuotaExceededError.

juliangruber commented 7 years ago

This may have a negative impact on web page loading performance

interesting! did you test this?

Also, the logging level will always be info in Safari's private mode, because Safari prevents writing to localStorage by throwing QuotaExceededError.

That's ok I think? So by default it won't log anything because microcomponent only logs on the debug level. Or do you develop in private mode?

dchest commented 7 years ago

interesting! did you test this?

I haven't measured it, but my guess is it would require at least one sync stat syscall to check if the file exists in browsers such as Chrome that store localStorage in files (Chrome actually uses one SQLite database per domain). I remember discussions about its performance from some years ago, e.g. https://www.stevesouders.com/blog/2014/02/11/measuring-localstorage-performance/ The difference may be tiny, so it may not matter at the end, just though it was worth mentioning, since I found it quite unusual for UI library to read/write local storage.

That's ok I think? So by default it won't log anything because microcomponent only logs on the debug level.

Good.

Or do you develop in private mode?

Nope.