In the process of creating a scripts and styles manager for a WordPress-based single page application, I initially believed that simply loading missing scripts on each route change would suffice. However, I now understand that certain scripts need to be executed again with every route or page change, such as those tracking user interactions with the content. Additionally, maintaining the order of included styles is crucial, as some styles may need to be re-rendered after new ones are added in order to achieve the desired outcome.
Are there any established strategies for addressing this common issue with single page applications?
It seems that one approach could involve re-rendering all styles on each route change whenever new styles are introduced, while also predefining which scripts should be re-executed with every route change. This method may seem complex and potentially detrimental to the performance benefits of a single page application.