sandstorm / awesome-sustainable-software

In this list, we want to collect links, resources, and tips towards sustainable software developent. We especially want to highlight practical real-world tips which are directly applicable in practice.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Awesome Sustainable Software Development

About

In this list, we want to collect links, resources, and tips towards sustainable software development.

We especially want to highlight practical real-world tips which are directly applicable in practice.

Supported with ❤️ by sandstorm

We are currently on our journey towards establishing sustainability goals and principles in our day-to-day work - and we want to collaborate with others and form a community around this.

Content

Practices

Docker and Containerization

Reducing Docker Image Size

Often, docker images are quite big in terms of image size - more than 1 GB is pretty common in "classical applications".

  • Use the tool dive to analyze docker image size.
  • Try to reduce the number of image layers and installed packages.

Avoid running apps as root

Consider Best practices

Web Server Configuration

Activate GZIP Compression

Gzip compression needs to be explicitly activated in the server config (nginx/apache). With this, you can easily reach big improvements for transferred data, especially for text-like content.

Configure HTTP Caching

By leveraging and properly configuring HTTP caching, you can also reduce data sizes quite a lot.

Common practices include:

  • static assets (like JS/CSS) should be cached for a very long time and include a cache-bust mechanism
  • f.e. in Neos CMS, Images are stored content-addressed (i.e. the URL changes if the image contents changes) - in this case, these assets can be also cached for a very long time.
  • HTML pages should not have caching enabled, as this makes changing cached pages impossible during the cache lifetime.

Minify JS/CSS

JS/CSS/SCSS should be minified during the build. During this process, comments, white spaces etc are removed - and multiple scripts are concatenated to one big file (which is positive for compression ratios etc).

Rendering

Use WebP format

Images are often responsible for most of the traffic. By using the WebP format, you can compress graphics lossy or lossless, such that they are 30% smaller than PNGs or JPGs.
By using the <picture> tag, you can support fallbacks for older browsers.

Optimize your images

  • use (lossy) compression
  • consider dithering for your images

Lazyly load offscreen images

By loading offscreen images only, when they enter the viewport for the first time, you can drastically reduce the weight of your webpage and save a lot of transferred megabytes. See for example the new loading attribute on image and iframe tags. For support of older browsers see javascript solutions (e.g. https://github.com/aFarkas/lazysizes).

Reduce colors in images

For quite some PNG or GIF images, you can drastically reduce the number of colors until you notice a visual difference. Sometimes, 6 or 4 colors are enough, sometimes 32 or 16. With this trick, you can reduce up to 90% of the file size.

Only use pictures, where relevant

Pictures are a major source of traffic. Consider using less pictures, where they are not necessary, or transporting the information through different means (text, colors, …)

Use videos as little as possible

  • avoid background videos
  • avoid auto-playing videos
  • compress your video

self host your fonts

When embeddings fonts from external font services, user data is passed to external parties. This is bad privacy practice. Opposed to this, self-hosted fonts add to the transmitted data.

Consider System Fonts

System fonts are already installed on your users device and don't need to be downloaded.

Optimize your font usage

  • load only the font-weights you need
  • use variable fonts as all styles can be embedded into one small file
  • use the woff2 file format, as it is the smallest to date
  • create a subset of only the characters you use

Application Configuration

Caching for reducing CPU load

Prefer event pushing over event polling

"And now?", "And now?", "And now?", "And now?", "And now?"

minimize number of requests

minimize number of transmitted bytes

  • minimize intermediate results
  • … apply filter on server (instead of client)
  • … or on database
  • design APIs based on the user perspective

cache large results

render only what has changed

Tracking

use existing metrics

Eg use web server logs to count number of visits per page.

track a sample set only

Do you need to track every visitor or one out of 100?

avoid dark patterns

For example in cookie banners, make the accept all and reject all button visually/hirarchically equally important. Clearly mark ads. Don't put pressure on your users ("only 3 left", "SALE: 7 hours left", …)

Think twice before using a pop-up

Can you inline consent modals for external content? Does your site really need external cookies?

Development and Staging

plan for local development

Make your project starts with one or two commands. Consider using our Dev Script Runner

plan for staging environments

limit execution of CI/CD pipelines

  • do I need to redeploy on readme changes
  • and run E2E tests after typo fixes

testing

Make writing tests part of your projects. Use efficient test scopes (E2E tests versus unit test).

consider alternatives for tools and libraries when starting a project

don't use AI for trivial tasks

Prefer adequate algorithms.

readable code

Follow best practices to structure your code, eg

enable others to maintain you project

  • aim for open source projects
  • do not re-implement things
  • pick a license, which allows others to improve/continue the project
  • use contracts, which allow your customers to migrate to another agency

measure and improve quality

What you can't measure, you can't manage. (Peter Drucker)

Avoid waste

abandon dead projects

only develop what will be used

shutdown idle servers

shutdown unused services

scale to zero or terminate

think of your data retention policy

delete no longer needed data, ie

  • logs and statistics
  • old application version
  • CI/CD results and artifacts

Hosting

co-locate small services

eg by using VMs, Kubernetes or serverless computing

choose green hosters

We use Hetzner.

Use a data centre close to your users

deploy a secure SSH configuration

ie no root and password logins

plan for regular updates

throttle metric collection

You do not need to check the remaining disk space every minute 😉.

Accessibility

Follow Awesome Accessibility

Knowledge Base

Base Research and Knowledge

Thank You ❤️

Thank You Ole Langbehn @neurolabs for pointing us towards nachhaltiges-webdesign.jetzt.

About

In this list, we want to collect links, resources, and tips towards sustainable software developent. We especially want to highlight practical real-world tips which are directly applicable in practice.