Make your site greener with GreenIT-Analysis

By analysing the page’s Document Object Model (DOM), as well as the number of http requests and JS validation, the tool provides a report and practical indications that help developers to optimise the design of their site to make it less energy-consuming. Furthermore, this analysis also allows internet users to judge the ecological impact of the sites they visit.

However, although useful, this method is still incomplete: its use is currently limited to studying a single page and still requires an action from the operator for each new analysis. On its own it therefore does not allow analysis of a whole website.
One interface to control them all!
In order to automate usage of the tool for a whole website, we have created a version of the extension with a command-line interface (CLI). This launches a Chromium browser in the background, controlled using Puppeteer, which opens each page to be analysed and emulates the extension’s operation.
Thanks to Chromium and Puppeteer, the simulation is automatically executed as a background task. The interface that allows the execution of this simulation then becomes a CLI.

Puppeteer retrieves each result and temporarily records them in JSON files. Several analyses can even be performed “in parallel” so as to avoid idle time, such as loading of a page.
Once all the pages are analysed, a summary file is produced that groups all of these results as well as an overall report. The developer thus has an overview of the environmental impact of their whole site and any indications that may be useful to optimise it.

Green screen!
Usage evolves and these days mobile browsing is as important as the traditional computer-based approach. It becomes essential to consider optimising websites for these consumption modes. For example, an image designed solely for a computer screen will be reduced on a mobile device, thus wasting precious resources in downloading a larger image than necessary.
This will result in a lower ecological score for this platform. In order to limit these inconveniences, GreenIT-Analysis therefore emulates a viewing platform according to the medium (desktop, Galaxy S9, Galaxy S20, iPhone 8, iPhone 8 Plus, iPhone X, iPad, etc.).
DevOps: the virtuous cycle
This method makes it possible to now integrate this automatic analysis process in a general approach. By combining the CLI and GitLab pipelines, it becomes conceivable for example to automate the analysis of sites after every modification.
Finally, in the same way as the indicators for assessing code quality, information related to a platform’s ecological impact should eventually be integrated to other tools such as SonarQube, in order to have an overall view within a single interface.

A project that we are currently working on…