Hacker News new | ask | show | jobs
by Theodores 2583 days ago
The web is not very green or very accessible. Every bloated web page requires a lot of electrons to be moved around.

Recently the web has evolved with CSS Grid and this means that you no longer need to have web pages made of 'div soup' with every 'div' using half a dozen non-semantic class attributes.

It is extremely rare for a web page to be 10% or higher in actual content, if you look at the actual document and don't even consider the images/scripts/stylesheets. Most of the web could be at the 33% mark if you strip the presentational markup away and just use HTML5 elements, styling them with CSS Grid. The benefits of writing this way are many, apart from being green, such a page is accessible because useful elements are used for the page, e.g. 'nav' instead of 'div', and easier to maintain, because the content is kept simple. There is also SEO benefit from having a quicker to download page that is a fraction of the size.

Now you may scoff at saving a few bytes from a few web pages but the savings add up, get one template right for a website that gets used by a few million people on a daily basis and you are suddenly saving gigabytes. People's phone batteries last longer, cell towers don't have to do as much work, server rooms can run cooler, it is a bigger win than people think.

Once upon a time we thought nothing of single use food containers or excess packaging, the humble 'div' with its framework class attributes double-wrapping every block of content on the page with a few 'span' elements thrown in for good measure is possibly more wasteful, at least you can reuse plastic bags, you can't reuse a 'div' that has been beamed across the airwaves from the far side of the globe.

There are laws coming along meaning that web pages have to be accessible. You can make them accessible in a lip service way or re-write them with maintainable, CSS-Grid styled HTML5 to deliver a first class accessible experience. In the EU there is a two year period for the public sector to get their act together on this.

Writing HTML without the div where you focus on document structure and use the right elements is very easy, as is using CSS Grid. But we are in an industry where the mindset is to work from a visual mockup and to then paint by numbers gormlessly using the dreadful div element that has no place in modern HTML and very much goes against the 'separation of concerns'.

The world needs someone to teach a new intake of web developers how to write actual HTML, leaving the build tools and hacks far behind, more of a focus on the written word rather than the overly complex tech.

We have had revolutions in web design, for instance 'responsive' was a thing. If we can have actual HTML instead of bloated presentational markup then there will be some old timers who won't get it, but this easier way should be well received. Right now though dev teams are very much geared up for over complicating projects and not even thinking to use just the HTML5 elements in a content first type of way. Hierarchies of teams are built around anachronistic 'agile' processes that are doomed to result in bloated div websites.

Unless there is nuclear war then we are not going back on the web, it is here to stay and be improved on. Be that improvement. Teach people how to write web pages the easy way, enable others to think differently and not be using tired Stack Overflow 'div' solutions that were okay a decade ago.

The maths of the CO2 saving is not easy to work out. But then it is. HTML is the language of the web and web pages are what we read. This page you are reading right now is HTML and not some JSON stringified thing. Coding the lean HTML5 way does get your HTML document size halved, plus the lights don't have to be on as long to write it in the first place.

You can do all of this stuff a lot easier than the stuff you have done thus far. I don't think your skill set is in 'planting trees'. Nobody is looking for 'green HTML developers' but there is this legislative requirement for accessible HTML. Start selling yourself to them.

1 comments

I can't tell if this is a joke or not, but HTML5 and lighter web pages are not a solution to climate change. There's no way in the world that math works out.
We are doomed anyway. There is no point 'raising awareness' or writing to your MP. Single handedly nobody can change magically provide the solution you seek.

But half the world spends half their time on their phone. Halve the bytes and bandwidth needed for that and make things accessible - what is not to like? I bet that changing the way we do web pages to remove old fashioned bloat saves more penguins than your suggestion.

My suggestion was written specifically for the questioner based on their skillset. Not a one size fits all solution for everyone.

Please do the maths for me after refactoring a web page of your choosing so you have an idea of the gains. Don't be a blocker, present some sums.