PageSourceSearch

https://swynx.io/assets/green-software-dead-code-DWG381ac.js

js swynx.io collected 2026-10-05 06:32:29 UTC 23,867 bytes, 1 lines download raw bytes

1import{j as e}from"./index-CBC1vxyu.js";import{u as r,S as a,B as s}from"./SwynxLayout-BcEFCgca.js";import{u as i}from"./useJsonLd-CzM7lf6u.js";import{C as o}from"./calendar--pAtOWNf.js";import{A as t}from"./arrow-right-BhBRSPkq.js";import"./utils-CkYB-R1u.js";import"./createLucideIcon-D63tVfJx.js";function p(){return r({title:"Dead Code and Software Carbon Footprint: The Green Software Case for Cleanup | Swynx",description:"Dead code wastes compute. Every CI build, every deployment, every serverless cold start processes files nobody uses. Removing dead code is the easiest way to reduce your software's carbon footprint.",path:"/blog/green-software-dead-code"}),i({"@context":"https://schema.org","@type":"Article",headline:"Dead Code and Software Carbon Footprint: The Green Software Case for Cleanup",description:"Dead code wastes compute. Every CI build, every deployment, every serverless cold start processes files nobody uses. Removing dead code is the easiest way to reduce your software's carbon footprint.",author:{"@type":"Organization",name:"Swynx",url:"https://swynx.io"},publisher:{"@type":"Organization",name:"OYNK",url:"https://oynk.co.uk"},datePublished:"2026-02-07",keywords:["green software dead code","software carbon footprint","sustainable software development","dead code environmental impact","green software foundation","software sustainability","ESG software metrics"]}),e.jsxs(a,{children:[e.jsx("article",{className:"py-24 bg-[#0a0a0a] text-white",children:e.jsx("div",{className:"container mx-auto px-6",children:e.jsx("div",{className:"max-w-3xl mx-auto",children:e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/50 text-sm mb-4",children:[e.jsx(o,{className:"w-4 h-4"}),e.jsx("span",{children:"February 2026"})]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-6",children:"Dead Code and Software Carbon Footprint: The Green Software Case for Cleanup"}),e.jsx("p",{className:"text-xl text-white/70",children:"Dead code increases your software's carbon footprint by forcing every CI build, every deployment, and every serverless cold start to process files that serve no purpose. Removing it is the single easiest way to reduce software emissions — no architecture changes, no infrastructure migration, no code rewriting. Just delete what is unused."})]})})})}),e.jsx("section",{className:"pb-24 bg-[#0a0a0a] text-white",children:e.jsx("div",{className:"container mx-auto px-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto prose prose-invert prose-lg",children:[e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"The Environmental Cost of Dead Code"}),e.jsx("p",{className:"text-white/70",children:"Every file your build system processes burns CPU cycles. Every CPU cycle consumes electricity. Every kilowatt-hour of electricity has a carbon cost. This chain — from dead file to carbon emission — is short, direct, and measurable. Yet it is almost universally ignored."}),e.jsx("p",{className:"text-white/70",children:"The Green Software Foundation identifies eliminating waste as a core principle of sustainable software development. Their reasoning is straightforward: if your software does unnecessary work, it consumes unnecessary energy. Dead code is the purest form of unnecessary work — files that exist in your repository, get cloned, installed, parsed, linted, tested, bundled, and deployed, but contribute nothing to the running application."}),e.jsxs("p",{className:"text-white/70",children:["This is not a theoretical problem. ",e.jsx("a",{href:"/blog/we-scanned-1000-repos",className:"text-primary hover:underline",children:"Our research across 1,001 repositories"})," found that the average project carries 4.09% dead code — 53,505 dead files out of 1,309,402 scanned. Every one of those files is processed on every build. In organisations running hundreds of CI pipelines per day across dozens of repositories, the wasted compute adds up to a meaningful carbon cost."]}),e.jsx("p",{className:"text-white/70",children:"The uncomfortable truth about green software is that most carbon reduction strategies require significant engineering investment: rewriting services in more efficient languages, migrating to carbon-aware cloud regions, optimising database queries. Dead code removal requires none of that. It is the lowest-hanging fruit in the entire sustainable software development toolkit."}),e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"Where Dead Code Wastes Energy"}),e.jsx("p",{className:"text-white/70 mb-6",children:"Dead code does not waste energy in one place. It wastes energy everywhere, at every stage of the softw
1are lifecycle. Here are the five primary channels:"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 not-prose mb-8",children:[e.jsxs("div",{className:"border border-white/10 rounded-lg p-6 bg-white/[0.02]",children:[e.jsx("h3",{className:"font-bold text-white mb-2",children:"CI/CD Pipelines"}),e.jsx("p",{className:"text-sm text-white/60",children:"Every build, lint, and test run processes dead files. CI pipelines run hundreds of times per day. Each run clones the full repository, installs dependencies, parses every source file, runs linters across every matched file, and executes test suites that may include orphaned tests for deleted features."})]}),e.jsxs("div",{className:"border border-white/10 rounded-lg p-6 bg-white/[0.02]",children:[e.jsx("h3",{className:"font-bold text-white mb-2",children:"Docker Image Builds"}),e.jsx("p",{className:"text-sm text-white/60",children:"Dead files are copied into Docker images, inflating image size. Larger images mean more storage in registries, more network transfer during deployments, and longer pull times on every container start. Every byte transferred consumes energy at every hop between data centres."})]}),e.jsxs("div",{className:"border border-white/10 rounded-lg p-6 bg-white/[0.02]",children:[e.jsx("h3",{className:"font-bold text-white mb-2",children:"Serverless Cold Starts"}),e.jsx("p",{className:"text-sm text-white/60",children:"Serverless functions load their entire deployment package on cold start. More files mean slower initialisation, longer execution time, and more compute billed. Dead code in a Lambda or Cloud Function directly increases the carbon cost of every invocation after a cold start."})]}),e.jsxs("div",{className:"border border-white/10 rounded-lg p-6 bg-white/[0.02]",children:[e.jsx("h3",{className:"font-bold text-white mb-2",children:"CDN Bandwidth"}),e.jsx("p",{className:"text-sm text-white/60",children:"Dead code that survives bundling — through side effects, barrel file re-exports, or bundler misconfiguration — inflates JavaScript bundles served to every user. Larger bundles mean more transfer over CDN edge networks, more parsing on user devices, and more battery drain on mobile."})]}),e.jsxs("div",{className:"border border-white/10 rounded-lg p-6 bg-white/[0.02] md:col-span-2",children:[e.jsx("h3",{className:"font-bold text-white mb-2",children:"Developer Machines"}),e.jsx("p",{className:"text-sm text-white/60",children:"IDEs index every file in the project. Local builds process every source file. TypeScript's language server analyses dead files on every keystroke. Across a team of 50 developers, each running local builds multiple times per hour, the cumulative energy cost of processing dead code on developer machines is substantial."})]})]}),e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"Quantifying the Impact"}),e.jsx("p",{className:"text-white/70",children:"Let us work through a back-of-envelope calculation to make this concrete. Consider a mid-sized engineering organisation with the following profile:"}),e.jsxs("ul",{className:"space-y-2 text-white/70 mb-4",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"500 CI builds per day"})," across all repositories and branches"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"5 minutes average build time"})," including linting, type-checking, testing, and bundling"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"4.09% dead code"})," (the average from our benchmark data)"]})]}),e.jsx("p",{className:"text-white/70",children:"If dead code accounts for 4.09% of every build, that is approximately 12.3 seconds wasted per build. Across 500 daily builds, that is 6,135 seconds — roughly 102 minutes — of wasted compute every day. Over a month, that comes to 51 hours of CI runner time spent processing files that nobody uses."}),e.jsx("p",{className:"text-white/70",children:"Expressed in energy terms: a standard cloud CI runner consumes approximately 50–100 watts. At 75 watts average, 51 hours of wasted compute per month equals 3.8 kWh. That may sound small for a single organisation, but multiply it across the millions of CI pipelines running globally and the aggregate waste becomes significant."}),e.jsxs("p",{className:"text-white/70",children:["The Green Software Foundation's Software Carbon Intensity (SCI) metric provides a formal framework for this calculation. SCI measures the carbon emissions per unit of work: ",e.jsx("code",{className:"text-white/90 bg-white/10 px-1.5 py-0.5 rounded text-sm",children:"SCI = ((E * I) + M) / R"}),", where E is energy consumed, I is the carbon intensity of the grid, M is the embodied carbon of hardware, and R is the functional unit. Dead code directly inflates E without increasing R — it raises your SCI score for zero functional benefit. Removing dead code is a pure SCI improvement."]}),e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"ESG Reporting and Dead Code"}),e.jsx("p",{className:"text-white/70",children:"Companies are increasingly required to report on environmental, social, and governance (ESG) metrics. For technology companies, software sustainability is a growing component of that reporting. The challenge has always been measurement: how do you quantify the environmental impact of your software?"}),e.jsx("p",{className:"text-white/70",children:'Dead code percentage provides a concrete, measurable, and improvable metric for ESG sustainability reporting. Unlike vague commitments to "greener engineering practices," dead code is a 
1number you can track quarter over quarter, set targets against, and demonstrably improve. It directly correlates with wasted compute, which directly correlates with energy consumption and carbon emissions.'}),e.jsx("p",{className:"text-white/70 mb-4",children:"A dead code metric is compelling for ESG reporting because it satisfies all three criteria that auditors and stakeholders look for:"}),e.jsxs("ul",{className:"space-y-2 text-white/70 mb-4",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Measurable"})," — automated scanning produces an exact dead file count and percentage, reproducible by any auditor running the same tool"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Actionable"})," — unlike carbon intensity of the power grid (which you cannot control), dead code is entirely within your engineering team's control to reduce"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Traceable"})," — every dead file removed can be linked to a specific commit, a specific reduction in build time, and a corresponding reduction in compute energy"]})]}),e.jsxs("p",{className:"text-white/70",children:["Swynx provides ",e.jsx("a",{href:"/features/esg",className:"text-primary hover:underline",children:"ESG-ready reporting"})," that maps dead code metrics directly to sustainability frameworks. The reports include historical trends, estimated carbon savings from cleanup, and exportable data for inclusion in corporate sustainability disclosures."]}),e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"The Green Software Foundation Principles"}),e.jsx("p",{className:"text-white/70",children:"The Green Software Foundation defines a set of principles for building sustainable software. Dead code removal maps directly to three of them:"}),e.jsx("h3",{className:"text-xl font-bold mt-8 mb-4 text-white",children:"Energy Efficiency"}),e.jsx("p",{className:"text-white/70",children:"The principle: use the least amount of energy possible. Dead code removal reduces energy consumption at every stage of the development lifecycle. Fewer files to parse, fewer files to lint, fewer files to bundle, fewer bytes to transfer, fewer files for IDEs to index. The reduction is proportional — removing 4% dead code reduces the computational work of file-processing stages by approximately 4%."}),e.jsx("h3",{className:"text-xl font-bold mt-8 mb-4 text-white",children:"Hardware Efficiency"}),e.jsx("p",{className:"text-white/70",children:"The principle: use the least amount of embodied carbon possible. Every CI runner, every deployment server, and every developer machine has embodied carbon — the emissions produced during its manufacture. When dead code forces these machines to do unnecessary work, it wastes a portion of their useful lifespan on valueless computation. Removing dead code means existing hardware serves its functional purpose for longer before requiring replacement, reducing the amortised embodied carbon per unit of useful work."}),e.jsx("h3",{className:"text-xl font-bold mt-8 mb-4 text-white",children:"Carbon Awareness"}),e.jsx("p",{className:"text-white/70",children:"The principle: do more when the electricity is clean and less when it is dirty. Dead code removal supports carbon awareness by reducing the baseline compute load. When your CI pipeline processes fewer files, the window of computation is shorter, giving you more flexibility to schedule builds during periods of low carbon intensity on the grid. A build that takes 5 minutes can be more easily shifted to off-peak hours than a build that takes 5 minutes plus 12 seconds of dead code processing — especially when multiplied across hundreds of daily runs."}),e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"Quick Wins: The Fastest Path to Greener Software"}),e.jsx("p",{className:"text-white/70",children:"Most green software strategies require significant investment. Migrating to a more carbon-efficient cloud region, rewriting performance-critical services, or optimising database queries all deliver real results but demand weeks or months of engineering time. Dead code removal is different. It is the fastest way to reduce your software's carbon footprint because the improvement is immediate and requires no changes to your architecture, infrastru
1cture, or application logic."}),e.jsx("p",{className:"text-white/70 mb-4",children:"Here is what you can achieve in a single afternoon:"}),e.jsxs("ul",{className:"space-y-2 text-white/70 mb-4",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Scan your codebase"})," — run ",e.jsx("code",{className:"text-white/90 bg-white/10 px-1.5 py-0.5 rounded text-sm",children:"swynx scan ."})," to identify every dead file. This takes seconds and requires no build step."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Remove dead files safely"})," — run ",e.jsx("code",{className:"text-white/90 bg-white/10 px-1.5 py-0.5 rounded text-sm",children:"swynx scan . --fix --dry-run"})," to preview what would be removed, then ",e.jsx("code",{className:"text-white/90 bg-white/10 px-1.5 py-0.5 rounded text-sm",children:"swynx scan . --fix"})," to execute the removal with automatic snapshot creation for rollback."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Verify with your test suite"})," — if tests pass, the code was genuinely dead. If anything breaks, ",e.jsx("code",{className:"text-white/90 bg-white/10 px-1.5 py-0.5 rounded text-sm",children:"swynx rollback"})," restores everything instantly."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Set up a CI quality gate"})," — add ",e.jsx("code",{className:"text-white/90 bg-white/10 px-1.5 py-0.5 rounded text-sm",children:"swynx scan . --ci --baseline origin/main"})," to your ",e.jsx("a",{href:"/blog/dead-code-ci-cd-pipeline",className:"text-primary hover:underline",children:"CI/CD pipeline"})," to prevent new dead code from accumulating. This is the single most important step for long-term sustainability."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Measure the impact"})," — compare build times before and after. Track your dead code percentage over time. Use the ",e.jsx("a",{href:"/features/esg",className:"text-primary hover:underline",children:"ESG reporting feature"})," to translate the reduction into estimated carbon savings for stakeholder reporting."]})]}),e.jsx("p",{className:"text-white/70",children:"The beauty of this approach is its simplicity. You are not optimising algorithms, refactoring architectures, or negotiating with cloud providers. You are deleting files that nobody uses. The carbon saving is a direct consequence of doing less unnecessary work."}),e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"Sustainable Softw
1are Development Beyond Dead Code"}),e.jsx("p",{className:"text-white/70",children:"Dead code removal is a starting point, not an endpoint. Once you have eliminated the obvious waste, there are several complementary strategies that further reduce your software's carbon footprint:"}),e.jsxs("ul",{className:"space-y-3 text-white/70 mb-4",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Reduce bundle sizes"})," — tree-shaking removes dead exports from reachable files, but dead file removal catches entire unreachable modules that tree-shaking never sees. Together they minimise the JavaScript shipped to users. See ",e.jsx("a",{href:"/blog/reduce-bundle-size-dead-code",className:"text-primary hover:underline",children:"reducing bundle size with dead code removal"}),"."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Optimise build pipelines"})," — fewer files to process means faster builds, which means shorter CI runner reservations and lower energy consumption. See ",e.jsx("a",{href:"/blog/reduce-build-time-remove-dead-code",className:"text-primary hover:underline",children:"reducing build time by removing dead code"}),"."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Unused dependency removal"})," — packages declared in your manifest but never imported still get installed, downloaded, and resolved on every build. Removing them reduces network transfer and install time."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Efficient Docker images"})," — slim images based on Alpine or distroless base images, combined with dead code removal, minimise the bytes transferred across networks during deployment."]}),e.jsxs("li",{children:["• ",e.jsx("strong",{className:"text-white",children:"Carbon-aware scheduling"})," — once your builds are lean, schedule non-urgent CI runs (nightly builds, batch jobs) during periods of low carbon intensity on your cloud provider's grid."]})]}),e.jsx("p",{className:"text-white/70",children:"Each of these strategies contributes incrementally to a lower SCI score. But dead code removal is the one that requires the least effort for the most immediate impact. Start there, measure the improvement, then expand to the broader sustainability toolkit."}),e.jsx("h2",{className:"text-2xl font-bold mt-12 mb-6",children:"Getting Started"}),e.jsxs("p",{className:"text-white/70 mb-4",children:[e.jsx("a",{href:"/scan",className:"text-primary hover:underline",children:"Scan your codebase free"})," at swynx.io to see how much dead code your project carries. The scan takes seconds, covers 26 programming languages, and requires no build step or configuration. From there, use the ",e.jsx("a",{href:"/features/esg",className:"text-primary hover:underline",children:"ESG reporting feature"})," to quantify the environmental impact of your dead code and track improvement over time."]}),e.jsxs("p",{className:"text-white/70 mb-8",children:["For a deeper technical guide on finding and removing dead code, see ",e.jsx("a",{href:"/blog/how-to-find-dead-code",className:"text-primary hover:underline",children:"how to find dead code in any codebase"}),". For setting up automated prevention, see ",e.jsx("a",{href:"/blog/dead-code-ci-cd-pipeline",className:"text-primary hover:underline",children:"dead code detection in CI/CD pipelines"}),". For the full documentation, visit the ",e.jsx("a",{href:"/docs",className:"text-primary hover:underline",children:"docs"}),"."]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-16",children:[e.jsx(s,{size:"lg",className:"text-base px-8",style:{height:"56px"},asChild:!0,children:e.jsxs("a",{href:"/scan",children:["Scan Free ",e.jsx(t,{className:"w-4 h-4 ml-2"})]})}),e.jsx(s,{size:"lg",variant:"outline",className:"text-base px-8 border-white/30 text-white hover:bg-white/10",style:{height:"56px"},asChild:!0,children:e.jsx("a",{href:"/features/esg",children:"ESG Reporting"})}),e.jsx(s,{size:"lg",variant:"outline",className:"text-base px-8 border-white/30 text-white hover:bg-white/10",style:{height:"56px"},asChild:!0,children:e.jsx("a",{href:"/docs",children:"Read the Docs"})})]}),e.jsxs("div",{className:"border-t border-white/10 pt-12 mt-12",children:[e.jsx("h2",{className:"text-2xl font-bold mb-8",children:"Related Posts"}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-3 not-prose",children:[e.jsx("a",{href:"/blog/reduce-build-time-remove-dead-code",className:"block group",children:e.jsxs("div",{className:"p-6 rounded-2xl border border-white/10 bg-[#0a0a0a] transition-colors hover:border-white/25 hover:bg-white/[0.02] h-full",children:[e.jsx("h3",{className:"font-bold mb-3 group-hover:text-white/90 transition-colors",children:"Reduce Build Time by Removing Dead Code"}),e.jsx("p",{className:"text-sm text-white/60 mb-4",children:"Your bundler processes every file it can reach. If 4% of those files are dead, you are wasting 4% of every build."}),e.jsxs("span",{className:"text-primary text-sm flex items-center gap-1",children:["Read more ",e.jsx(t,{className:"w-3 h-3"})]})]})}),e.jsx("a",{href:"/blog/how-to-find-dead-code",className:"block group",children:e.jsxs("div",{className:"p-6 rounded-2xl border border-white/10 bg-[#0a0a0a] transition-colors hover:border-white/25 hover:bg-white/[0.02] h-full",children:[e.jsx("h3",{className:"font-bold mb-3 group-hover:text-white/90 transition-colors",children:"How to Find Dead Code in Any Codebase"}),e.jsx("p",{className:"text-sm text-white/60 mb-4",children:"Four methods for detecting unused files, dead exports, and orphaned modules across every major programming language."}),e.jsxs("span",{className:"text-primary text-sm flex items-center gap-1",children:["Read more ",e.jsx(t,{className:"w-3 h-3"})]})]})}),e.jsx("a",{href:"/blog/clean-up-codebase",className:"block group",children:e.jsxs("div",{className:"p-6 rounded-2xl border border-white/10 bg-[#0a0a0a] transition-colors hover:border-white/25 hover:bg-white/[0.02] h-full",children:[e.jsx("h3",{className:"font-bold mb-3 group-hover:text-white/90 transition-colors",children:"How to Clean Up Your Codebase"}),e.jsx("p",{className:"text-sm text-white/60 mb-4",children:"A systematic six-step approach to removing dead code, unused dependencies, orphaned tests, and stale c
1onfiguration."}),e.jsxs("span",{className:"text-primary text-sm flex items-center gap-1",children:["Read more ",e.jsx(t,{className:"w-3 h-3"})]})]})})]})]})]})})})]})}export{p as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.