nolanlawson / pokedex.org

Offline-capable Pokédex web site (unmaintained)
https://www.pokedex.org
Apache License 2.0
2.27k stars 325 forks source link

(#2) - use hashchange to fix back button and links #60

Closed nolanlawson closed 7 years ago

nolanlawson commented 7 years ago

I had originally planned on an elaborate solution involving the History API and a service worker that was capable of serving up fully static versions of the Pokémon detail pages, as well as prebuilt HTML files for all 600+ Pokémon to be hosted on S3 (aka "trisomorphic rendering"). This would enable it to work without JS and to gracefully handle refreshes / new navigations etc. with or without service worker.

Ultimately I think it makes more sense to just do the easiest possible thing and use the hashchange event on a single HTML file. This at least unbreaks the back button and gives us routing, even if it's not the hip modern way to do stuff. It's been a year and I clearly don't have the time to implement the full trisomorphic thing. This is easier and gets the job done. It took me like 2 hours to implement.

I used Navigo because the other routing libraries at glanced at seemed way too complicated for what I was trying to do. Navigo is simple and is like 2kB.