4 ms·
I'm no expert at rendering HTML, but I wonder if HTML can be "optimized" so that some css rules and redundant divs can be "merged". If that can be done server-
by jokoon 7y ago
I'm no expert at rendering HTML, but I wonder if HTML can be "optimized" so that some css rules and redundant divs can be "merged".
If that can be done server-side, it might reduce page weight. If it's not possible, well, I guess HTML should be removed from the face of the earth. The language has too much nonsense and ambiguity. The fact that html can now have its structure dynamically changed with javascript inserting string at random places means it will always let web developers build bloated websites like this.
I really don't know how to solve such problem. Usually the language will encourage the flawed usages it allows. A language must always put constraints to avoid unwanted usages. Either that or have browsers not display pages that are too large, by having a size limit or something of that fashion.
- oconnor663 7y agoI think most of the HTML you get from large websites is gzipped. Gzip is pretty good at compressing things like three nested div tags. So I think if you tried to build this sort of optimizer, you'd find that a big chunk of the plaintext savings gets lost through reduced compression efficiency. But who knows how much? Maybe it could help in some cases. (Though then of course you'd have to figure out how not to break CSS selectors.)
- beatgammit 7y agoYeah, CSS selectors in JavaScript would probably be the main issue here, and figuring out if a selector path is used is a very difficult problem to solve. I really wish we could just collectively move away from stupidly complex webpages and get back to JavaScript as optional for most pages. Once you eliminate JavaScript as a required component, you tend to design things more simply and page loads become lighter and faster. IMO, JavaScript should only be required for applications (maps, games, perhaps video playback), with everything else using primarily HTML and CSS. That would kind of put me out of a job though, but I think it would make the internet better, and it would certainly help improve efforts to improve accessibility.