A Clientside router in vanilla javascript for that sweet sweet performance
useage illustrated in the files above
router.js
is the main moduleviews.js
is the routing logic to be defined by the usermain.js
is the application of router on the DOM
Remember to import main.js
as type module
<script src="/js/main.js" type="module"></script>
- backend to handle initial requests (tools like express prefered as it handles static file serving logic)
- JS template literal syntax highlighter like lit-html to make life easier
- Current method of detecting navigation by browser's navigation buttons is ineffecient (setInterval every 20ms)
- Router doesnt have common features like redirect
- Router doesnt support component driven development cohesively (even though it wasnt designed to be meant to)