3.14 Use Standards-based JavaScript and APIs
Use JavaScript in an energy-efficient and accessible way, only using APIs and making external calls when this enhances a project’s sustainability.
Criteria
- Sustainable JavaScript: Machine-testable
Improve sustainability through accessible and performant code.- A handful of reasons JavaScript won’t be available
- Accessible JavaScript
- CanIUse
- Common Causes of Memory Leaks in JavaScript
- Comparing the Energy Efficiency of WebAssembly and JavaScript in Web Applications on Android Mobile Devices (PDF)
- Degree of internet freedom in selected countries according to the Freedom House Index in 2022
- Everyone has JavaScript, right?
- GPF – General Policy Framework (PDF) – 1.9 – Strategy (Interoperable Technologies)
- GPF – General Policy Framework (PDF) – 6.6 – Front-End (Sensor Requests)
- Hidden cost of frontend frameworks
- How To Test Your Website With JavaScript Disabled
- How Web Content Can Affect Power Usage
- Internet censorship and surveillance by country
- JavaScript dos and donts
- JavaScript isn’t always available and it’s not the user’s fault
- JavaScript for Web Designers
- JS Free
- Memory leaks: the forgotten side of web performance
- Optimizing Javascript for fun and for profit
- The Performance Inequality Gap
- W3C Web Performance Working Group
- WebAssembly versus JavaScript: Energy and Runtime Performance
- Why care about the no-JS experience?
- Sustainable APIs: Machine-testable
Integrate energy-relevant APIs – such as Battery Status, Compression Streams, Page Visibility, or Vibration – where these can reduce energy consumption. - API requests: Human-testable
Call client- or server-side APIs only when necessary. Equally, ensure an API is optimized to only send data that is actually required.- 9 Proven Strategies to Improve API Performance
- API Security Best Practices
- Common API mistakes and how to avoid them
- GPF – General Policy Framework (PDF) – 1.10 – Strategy (Documented APIs)
- Green API Design 1/5: Rates limiting for Sustainable APIs
- Green APIs: Developing Sustainable API’s with a Low Carbon Footprint
Benefits
- Conversion
Creating fallbacks for technology that might fail can ‘enable sales you would otherwise miss out on. - Economic
Providing easier, reliable access in more situations allows you to sell to more people. - Environment
Reducing unnecessary visual effects – such as animations – when a page is not visible, helps to prevent wasted processing in background tabs. This can potentially help users who leave multiple tabs open conserve battery. - Performance
Using low-impact scripting can reduce heavy codebase sizes. Providing fallbacks for unavailable JavaScript ensures older or less capable devices can still access your content. - Privacy
Allowing script-free users to easily access your content can protect the privacy of users with increased privacy needs.
GRI
- Materials: High
- Energy: High
- Water: High
- Emissions: High