<div id="cart" style="display:none">block</div>
<button type="button" id="button">Toggle</button>
<script>
try {
const cart = document.getElementById('cart');
const button = document.getElementById('button');
button.addEventListener('click', function() {
const isHidden = +(cart.style.display === 'none');
cart.style.display = ['none', 'block'][isHidden];
localStorage.setItem('cart-expanded', isHidden);
});
if (+localStorage.getItem('cart-expanded'))
button.click();
} catch (e) {
console.error(e);
};
</script>