meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ixc2024:tech:wfrontend:criteria:greencode [2024/05/22 14:32] – alesta | ixc2024:tech:wfrontend:criteria:greencode [2024/05/22 15:38] (current) – alesta | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Green Code Book ==== | + | ==== Green Code Suggestions |
- | Here are 20 best practices derived from the concepts in the "Green Code" book: | + | Here are ~20 best practices |
Reduce emissions: | Reduce emissions: | ||
* **Minimize Data Traffic:** Reduce the amount of data transferred by optimizing images, compressing files, and utilizing efficient formats. This includes using formats like WebP for images and minifying CSS, JavaScript, and HTML files. | * **Minimize Data Traffic:** Reduce the amount of data transferred by optimizing images, compressing files, and utilizing efficient formats. This includes using formats like WebP for images and minifying CSS, JavaScript, and HTML files. | ||
* **Implement Efficient Caching:** Use browser caching to store static resources locally on the user's device. This reduces the need for repeated downloads. | * **Implement Efficient Caching:** Use browser caching to store static resources locally on the user's device. This reduces the need for repeated downloads. | ||
- | * **Optimize Images and Videos:** Compress images and videos using tools like ImageOptim or HandBrake. Serve images in next-gen formats like WebP and videos in optimized formats like MP4. | ||
* **Lazy Loading:** Implement lazy loading for images and videos to ensure that they are only loaded when they enter the viewport. This reduces initial load times and data usage. | * **Lazy Loading:** Implement lazy loading for images and videos to ensure that they are only loaded when they enter the viewport. This reduces initial load times and data usage. | ||
+ | |||
+ | |||
+ | * **Optimize Images and Videos:** Compress images and videos using tools like ImageOptim or HandBrake. Serve images in next-gen formats like WebP and videos in optimized formats like MP4. | ||
+ | * **Use SVGs:** Where appropriate, | ||
+ | * **Optimize Forms and User Inputs:** Reduce the size of user-uploaded images and videos by cropping and compressing them before upload. Implement client-side validation to reduce unnecessary server requests. | ||
+ | |||
* | * | ||
+ | |||
+ | |||
* **Efficient Font Loading:** Use only the necessary font weights and styles. Consider using system fonts to reduce the need for external font loading. When using web fonts, ensure they are loaded asynchronously and consider subsetting fonts to include only the characters needed. | * **Efficient Font Loading:** Use only the necessary font weights and styles. Consider using system fonts to reduce the need for external font loading. When using web fonts, ensure they are loaded asynchronously and consider subsetting fonts to include only the characters needed. | ||
* **Efficient Animations: | * **Efficient Animations: | ||
+ | |||
+ | |||
* **Reduce HTTP Requests:** Combine files where possible (e.g., CSS sprites, combined JavaScript files) to minimize the number of HTTP requests required to load a page. | * **Reduce HTTP Requests:** Combine files where possible (e.g., CSS sprites, combined JavaScript files) to minimize the number of HTTP requests required to load a page. | ||
- | * **Use Content | + | * **Energy Efficient |
- | * **Use Efficient JavaScript Libraries: | + | * **Monitor and Optimize Performance: |
- | * **Optimize Forms and User Inputs:** Reduce the size of user-uploaded images and videos by cropping and compressing them before upload. Implement client-side validation | + | |
- | * **Static Site Generation: | + | |
- | * **Progressive Web Apps (PWAs):** Develop your site as a PWA to take advantage of offline capabilities and background syncing, reducing the need for constant data transfer. | + | |
- | * **Use SVGs:** Where appropriate, | + | |
- | * **Monitor and Optimize Performance: | + | |
- | Increase maintainability: | ||
- | * **Reduce Unused Code:** Regularly audit and remove unused CSS, JavaScript, and other resources. Tools like PurifyCSS can help identify and remove unused CSS classes. | ||
Accessibility: | Accessibility: | ||
Line 27: | Line 29: | ||
* **Responsive Design:** Use responsive design principles to ensure that your website adapts to various devices and screen sizes efficiently. This includes using media queries to load only the necessary resources for each device. | * **Responsive Design:** Use responsive design principles to ensure that your website adapts to various devices and screen sizes efficiently. This includes using media queries to load only the necessary resources for each device. | ||
* **Optimize for Accessibility: | * **Optimize for Accessibility: | ||
+ | |||
+ | |||
+ | Increase maintainability: | ||
+ | * **Reduce Unused Code:** Regularly audit and remove unused CSS, JavaScript, and other resources. Tools like PurifyCSS can help identify and remove unused CSS classes. | ||
+ | |||
Finally: | Finally: | ||
- | * **Educate and Collaborate:** Ensure | + | * **Holistic approach:** Understand both the business logic behind the solution |