Will the page load faster, provided that we will generate the entire dom via js? In fact, we will not have html markup and css code in files, and the whole house will be built through js, in fact we will have 1 file clogged with js code.

Is this approach faster than the standard one with html / css files?
Desirable detailed answers (like, why, etc.)

    2 answers 2

    First of all, you need to think about users. And users entering your site want one thing - to see the content, as quickly as possible. They do not want to look at the white screen.

    Therefore, the answer to your question will be the realization that you are more expensive - traffic or users.

    If you only have a link to .js in index.html , then such a file will load faster and not surprisingly, the size has been reduced exactly by .html . But the dom will be generated more slowly and until the entire file is uploaded, until the user can see the content, there will be a white screen.

    An alternative to this is a full-fledged .html , the content of which the user will see as soon as he loads the dom tree. And the scripts need to be placed at the very bottom of the body in order to start loading after forming the display. But in such cases, there will be no instant response of the application, as the scripts are still loaded, and after loading they will be executed.

    But personally, I tend to the second option, if we consider the standard web application.

      A good option is to do some preloader, which will show the user a more or less light prog bar or picture while the rest of the site content is loaded. For this, it is enough to place the code, styles and script of the preloader above all in index.html , then the user even with a weak Internet will see the page fully loaded and will not be upset by the white screen, etc. There is a good library for organizing a preloader, which will show the real progress of loading PreloadJS

      • With preloaders you have to be careful. Its use should be deliberate. It should be understood that the visitor comes to the site not to look at the ability of the developer. And it’s not interesting for him to watch instead of the content of the "spinner / twirl". - Vorobev Alexander
      • This is of course understandable, but if the page size is 3 + mb, then the preloader is a lesser evil than the layout that is skewed due to the underloaded content. To be inspired by the preloaders, it is enough to set the download speed limit at the level of regular 3g (chrome) in the developer console and watch the bugler) - Mikl
      • What does it have to do with a preloader? What is the layout? read the topic guys - deres
      • Moreover, if you are going to organize a dynamic home and manage content download via js, it gives you the opportunity to control this download and the display sequence of the downloaded one. What a big plus and directly relates to your question. In general, it is modern frontend, of course it works with a dynamic home, read about reactJs, requireJs - Mikl