Yeah! 😉 You would insert an external script call like
<script type="text/javascript" src="YOUR DOMAIN HERE/external.js"></script>
This would be called automatically if the user is online (and will be ignored if the user is offline).
Then, you can do ANYTHING like updating localStorage items:
https://stackoverflow.com/questions/37052087/how-do-i-update-localstorage-items