What is the algorithm for changing the template / page in a SPA in pure JS?

  • 0
    Greetings. Let's say I have a chat application that logically consists of two pages. First, the user goes to the main page, gets an id, indicates a nickname, creates or selects a room to enter. Those. there is a certain logical transition to another page, the html must completely change to display the interface of the room and all the scripts necessary for the room to work must work. And now I want to understand by what algorithm such a transition can be implemented without loading another page and saving the initial data in some local storage. So far, I have found all the spa examples in the form of something simple ala to update the post content and highlight the menu item without global changes on the page.
    JavaScript Anonymous, Apr 10, 2020

  • 1 Answers
  • 0
    If you do it smartly, you will end up writing your own vue / react, only worse.

    And on the stupid one: the content of the first page is display: none , the content of the second is display: block - it all lives at the same time, all connections and variables are preserved, pieces are hidden only visually.

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!