javascript – Localstorage on AMP theme

I have created a theme using AMP and in an area there is a form with checkboxes to browse articles depending on their taxonomies (in this case the taxonomies are styles)

I have made an example that I want to stay checked after refresh but it is not working

<amp-script src="https://wordpress.stackexchange.com/<?php ABSPATH; ?>/wp-content/themes/Amptheme1/template-parts/templates-tptf/ville/checkbox-action.js">
    <div class="container">
       <input type="checkbox" id="test7" class="linput" name="style()"
         value="Streetwear/Sportwear"/><label class="lelabel" for="test7"> 
          <h6>Streetwear/Sportwear</h6> 
         </label>
         <button type="button" onClick="save()">save</button>
    </div>
</amp-script>

and for the JS

function save() {   
var checkbox = document.getElementById("test7");
localStorage.setItem("test7", checkbox.checked);    
}

//for loading
var checked = JSON.parse(localStorage.getItem("test7"));
document.getElementById("test7").checked = checked;