Skip to main content

Copy of some Draft Web Development Guidelines

Tree shaking should be used to remove unnecessary code

Often when coding, projects can accumulate clutter and functions that are no longer used (due to newer, more effective features being developed). By utilizing tree shaking techniques, all the "dead wood" will be automatically dropped upon compilation, reducing a file's size.

Criteria: Remove redundancy

Machine-testable

Identify and eliminate unused and dead code within CSS and JavaScript.

Resources

Impact: Medium, Effort: Medium

GRI Impact of Tree shaking should be used to remove unnecessary code
GRI Impact
materials Medium
energy Medium
water Medium
emissions Medium
Benefits of this guideline
  • Environment: Removal of unused code eliminates wasted bytes from the rendering tree, which means less wasted download and potential processing time (which can be a battery-draining process).
  • Performance: Unused code will not impact visitors, yet it takes up space in the cache, RAM, and takes extra time to download and render. Clearing wasted space frees' visitor resources.
  • Economic: Unused code has a maintenance cost as it might affect other code, additionally, it's something else for developers to have to deal with unnecessarily.

Example
  • code export function read(props) { return props.book } import { read } from 'utilities'; eventHandler = (e) => { read({ book: e.target.value })}
  • content Tree Shaking.

Tags: