Skip to content

Instantly share code, notes, and snippets.

View OzanKurt's full-sized avatar
🍻
Cheers!

Ozan Kurt OzanKurt

🍻
Cheers!
View GitHub Profile
@OzanKurt
OzanKurt / localStorage.size.js
Created January 13, 2023 01:56 — forked from JustSteveKing/localStorage.size.js
A little script to check the size of your localStorage - for management purposes
let total = 0, amount, item;
for (item in localStorage) {
amount = ((localStorage[item].length + item.length) * 2);
total += amount;
}
console.log(`Total = ${(total / 1024).toFixed(2)}KB`);
@OzanKurt
OzanKurt / localStorage.async.js
Created January 13, 2023 01:56 — forked from JustSteveKing/localStorage.async.js
Using JavaScript Promises to stop render blocking with localStorage
class Storage {
get(item) {
const request = new Promise((resolve, reject) => {
let data = localStorage.getItem(item);
console.log(`Start of promise`);
(data) ? resolve(data) : reject();
});
request.then((data) => {
console.log(`promise resolved`);