Local storage instructor notes
Explain what happens when an HTML, with javascript, page is loaded
Explain what local storage is
Describe why local storage is useful
Use local storage to persist data
What happens when an HTML page with Javascript is loaded by the browswer?
In your teams, create a timeline of how the following HTML is loaded into a browswer
<!-- index.html -->
<html>
<head>
<script defer src="/main.js"><script/>
</head>
<body>
<h1> Hello World!</h1>
</body>
</html>
// main.js
const body = document.querySelector('body')
const name = document.createElement('p')
name.innerHTML = 'Roger'
body.appendChild(name)
How would the order change if you did not have the defer
keyword in the script
tag? Would any errors be triggered?
With your teams,
Reseach what local storage and summarize it
Identify 3 methods that allow you to interact with it
Find where to see the contents of local storage in your browswer development console
Why is local storage useful?
With your teams, establish why local storage would be useful
How do you use local storage to persist data?
Create a Todo application
Add items
Clear all items
Updated the todo application so that list items persist data