Created
March 6, 2021 20:21
-
-
Save nitayneeman/eb0d81ca721ddfc9978fe557ca8d8cc7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('hashchange', async () => { | |
// Extracts the new route | |
const route = window.location.hash.substr(1); | |
// Loads the module based on the route | |
const { myFunction } = await import(`./${route}.mjs`); | |
myFunction(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment