Addressfinder

The best way to find exact addresses in New Zealand

  • Skip to Main Navigation
  • Skip to Footer Sitemap
  • Skip to Top
  • Pricing
  • Features
    • Autocomplete
      Search addresses and locations as you type
    • Bulk Cleansing
      Verify a database of addresses
    • Geocode Addresses
      Collect addresses and GPS coordinates together
    • Bounding Box
      Collect all addresses within a defined area
    • MORE FEATURES
  • About us
  • Case studies
  • FAQ
  • Contact
  • Blog
  • JavaScript widget docs
  • API developer docs
  • Pricing
  • Features
    • Autocomplete
      Search addresses and locations as you type
    • Bulk Cleansing
      Verify a database of addresses
    • Geocode Addresses
      Collect addresses and GPS coordinates together
    • Bounding Box
      Collect all addresses within a defined area
    • MORE FEATURES
  • More
    • Company & product
      • About Us
      • Case Studies
      • FAQ
      • Partners
      • Blog
      Contact Us
    • Integrations
      • Magento
      • WooCommerce
      • BigCommerce
      • Salesforce
      • Shopify Plus
      See all integrations
    • JavaScript widget docs
      • Integration Guide
      • Widget Code Generator
      • Widget Reference
      • Code Examples
      See all JavaScript docs
    • API developer docs
      • Address Autocomplete
      • Address Metadata
      • Address Verification
      • API Errors
      See all API docs
  • Login
  • Blog
    • Technology
      • Saving the planet, 1024 bytes at a time

Saving the planet, 1024 bytes at a time

#Technology #Carbon Emissions #Environment #Javascript #Performance #Sustainability

Reducing the size of Javascript files can reduce your CO2 emissions

I recently read about this in Danny van Kooten’s blog post on the CO2 emission reductions he achieved through reducing the size of his Wordpress plugins.

I was inspired to see what efficiencies we could also make with our AddressFinder plugin. This story follows our investigation, challenges and how we were able to reduce our plugin size by 25%

AddressFinder plugin running on an address form AddressFinder plugin running on an address form

Can we reduce our file sizes too?

That got me wondering if AddressFinder could also make similar improvements. This would align with our company goals of having a reduced impact on the planet.

Could we reduce the file size of our Javascript code, and consequently reduce the emissions generated through network traffic and CPU utilisation?

When our customers use AddressFinder, they will typically download our Javascript library that runs the autocomplete service on their website. Until now, this library was 23.5 kB of compressed Javascript. The internals of this library include:

  1. An autocomplete library
  2. The AddressFinder business logic
  3. A cross-browser HTTP client
  4. Several Javascript polyfills

We realised that it may be possible to remove the HTTP client and the polyfills. These were included in the library to allow the service to work on very old browsers, including Internet Explorer 6 (which surprisingly is still used).

Challenges in supporting older browsers

Our desire to reduce the Javascript payload size, while also maintaining support for older browsers, was becoming a challenge. A new approach was required.

The solution is to freeze the library at the current version. This frozen version would be returned to Internet Explorer (version 6, 7, 8 and 9) users.

This would then allow us to drop the support for those rather ancient browsers in the current version, and as a result the HTTP client and the polyfills could be removed.

Result

We were able to carve off 5.9 kB with an end payload of 17.6 kB(compressed). A savings percentage of 25%

Emissions reduction calculation

Each month, our main Javascript library is downloaded 7.9 million times.

The total download reduction in gigabytes is:

7.9 million * 5900 bytes * 1,000,000,000 = 46.6 GB network traffic

Danny’s blog post outlines an approach for calculating the amount of energy needed to transfer 1 GB of data across a modern network connection. He selected an average figure of 0.5 kWh of electricity used for each GB.

46.6 GB network traffic * 0.5 kWh/GB = 23.3 kWh electricity

Most of our customers are in Australia, so we will use the federal average emissions figure:

23.3 kWh electricity * 0.9 kg CO2 / kWh = 21 kg CO2 each month

What does 21 kg of CO2 look like?

Danny compares his emissions with those emitted by driving his car. Funnily enough, his car is a Toyota Yaris — which Matt also drives.

The Yaris has an efficiency of 158.5 g CO2/km.

To emit 21 kg of CO2, you would have to drive this far in the Yaris:

21 kg CO2 / 0.1585 = 132.5 km each month

Savings

We reduced our Javascript payload by about 6 kB. Every month ongoing, our service will have reduced CO2 emissions by the equivalent of 132 km of driving. Not bad.

And, as the use of AddressFinder continues to grow, that 6 kB of Javascript reduction will have greater significance.

As Danny says:

the most important thing is to realise that the choices we make in developing for the web have consequences that really add up at scale

#Technology #Carbon Emissions #Environment #Javascript #Performance #Sustainability
Published: 12 August 2020
Nigel Ramsay
Nigel Ramsay
Addressfinder logo
Addressfinder provides speedy, accurate and dependable address autocompletion at a fair price. Easily integrate our address finder software with your site to start enjoying our address verification, address autocomplete and other address services today.

Sitemap

  • Home
  • About
  • Contact
  • Blog
  • FAQ
  • Pricing
  • Case Studies
  • Status Page
  • Privacy Policy
  • Terms & Conditions
  • Features
  • Address Metadata
  • Bulk Cleansing
  • Geocode Addresses
  • Reverse Address Lookup
  • Points of Interest
  • Street, Suburb & City Search
  • Bounding Box Search
  • Postcode Finder
  • Address Verification
  • Integrations
  • WooCommerce
  • BigCommerce
  • Shopify Plus
  • Magento
  • Salesforce
  • Spiffy Stores
  • iOS
  • Ruby
  • HubSpot
  • Drupal
  • Microsoft Dynamics 365
  • Vue
  • Gravity Forms
  • React
  • API Documentation
  • Address Autocomplete
  • Address Metadata
  • Address Verification
  • API Errors
  • Another 6 APIs
  • AU APIs specs
  • International APIs
  • Widget Documentation
  • Integration Guide
  • International Integration Guide
  • Code Generator
  • Code Examples
  • Javascript Reference
Addressfinder is also available in Australia
Terms and Conditions | Privacy
Copyright © 2022 Addressfinder, New Zealand