I have a project with 6 views (HTML). Each of these views has a corresponding view model (.js) and a stylesheet for that view only (.css).
Aurelia-cli does a wonderful job of repeating my file for free and combining all .js and .css files into a couple of files so that they can be referenced, while reducing download time and page size. Therefore, if I have a welcome folder with welcome.html, welcome.js and welcome.css, I can load the CSS for welcome.html with the following <require from="./welcome.css"></require> and CSS will be entered in the <head></head> tags when loading the page.
The problem is that when I go to the next view, the CSS rules from welcome.html / welcome.css are still in the <head> web page, so they still apply. After visiting all 6 submissions in my application, I now have 6 <style> tags in <head> with all the rules of all six pages that apply to every page that I visit, without unloading until the page is refreshed . Needless to say, after visiting a couple of pages the whole site becomes messy garbage.
So my questions
- Why is this feature
- Am I missing the best practice here?
- Is there a way to now load the CSS for the page when I visit, unload it when I delete it, and load new CSS pages in this place?
If I had a 10-page app with a global stylesheet, bootstrap, CSS animations, and an awesome font, at the end of the day I had 14 conflicting styles that are constantly being implemented in the html into which the rest of the application is embedded.
Any suggestions?
source share