I have created 2 js files in the server. One is for guests of the site, the other is for an authorized user. That is, roughly 2 applications, in each router and pages. In html I only have 1 file connected. It is rendered:
<body> <div id="app"></div> <script> window.onload = function func(){ function isAuthorized(){ return document.cookie.indexOf('cookie')===0; } if(isAuthorized()) { var s = document.createElement("script"); s.src = "app2.js"; s.id = "index_js"; document.getElementById("app_container").innerHTML = ""; document.getElementById("app_container").appendChild(s); } } </script> <div id="app_container"> <script id="index_js" src="app.js"></script> </div> </body> I thought to switch between these files using the check for the presence of cookies that the user receives during authorization. To this end, wrote a script that works when the page loads (you can see it above). However, it works clumsily and it seems to me that the reactor should have the means to work with such things. Please tell me how best to make such a transition?
render()or not? - Nofate ♦