https://github.com/darcdev/router-spa-vainilla
Vainilla Javascript router creation workshop
https://github.com/darcdev/router-spa-vainilla
Last synced: 11 months ago
JSON representation
Vainilla Javascript router creation workshop
- Host: GitHub
- URL: https://github.com/darcdev/router-spa-vainilla
- Owner: darcdev
- Created: 2020-04-21T23:09:23.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-21T23:13:28.000Z (almost 6 years ago)
- Last Synced: 2025-02-06T14:22:56.786Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Router Single Page Application (SPA)
## Vanilla Javascript router creation workshop
## Steps
**Load the route**
Identify where we are on the site. (Initial load of the route).
loadInitialRoute ()
**Compare the URL with a path**
The URL to which it moves us, must be compared with the routes we have.
matchUrlToRoute ()
**Update the URL in the navigation bar**
For this we will use the HTML pushState method.
`windows.history.pushState({},title,url)`
loadRoute ()
**Update the DOM with new content**
For this we are going to use innerHTML.
loadRoute ()