Skip to Main Content
Sustainable Web Design Logo
  • Home
  • Guidelines
  • Emissions
  • Ratings
  • Contact

◂ Web Development guidelines

3.3 Use Code-Splitting Within Projects

Web Development

When dealing with heavy components (such as JavaScript), the ability to modularize them into smaller pieces that can be loaded as and when required reduces the amount of redundancy and serves as a great way to make your scripts more sustainable.

Criteria

  • Code Splitting: Breakdown bandwidth-heavy components into segments that can be loaded as required.

Impact

Medium

Effort

Low

Benefits

  • Performance:
    Having smaller (modular) components allows for more optimized caching and loading only what code functions are required (which reduces the payload). Unused portions of a resource remain un-downloaded (potentially huge savings).
  • Economic:
    Reducing the size of large files will result in lower bandwidth bills for service providers.
  • Conversion:
    A faster website reduces the chance of abandonment (which is especially of concern for visitors of handheld devices).

GRI

  • materials: Medium
  • energy: Medium
  • water: Medium
  • emissions: Medium

Example

  • Code:
    link.addEventListener("click", (e) => {
    	e.preventDefault();
    	import("/modules/my-module.js")
    	.then((module) => {
    		/* Do something */
    	})
    	.catch((err) => {
    		console.error(err.message);
    	});});
  • Dynamic Imports.

Resources

  • Code splitting
  • Electricity Intensity of Internet Data Transmission
  • How code splitting increases performance
  • JavaScript performance
  • Mobile website Load Time Statistics
  • You Might Not Need

View the Guideline

Tags

PerformanceCSSJavaScript

Share

More web development guidelines

3.1 Identify Relevant Technical Indicators

Web Development

3.2 Minify Your HTML, CSS, and JavaScript

Web Development

3.4 Apply Tree Shaking To Code

Web Development

Learn about W3C’s Sustainable Web Interest Group:

A global community advancing sustainability on the web.

Explore the group

This site is brought to you by

Mightybytes Wholegrain Digital
Website Carbon

This page loaded in 0.25 seconds and emitted just 0.5g of CO2

Visit Website Carbon
Ecograder

How green is your website?

Visit Ecograder
© Copyright Sustainable Web Design 2025. Privacy Policy.