Add content to Frontend Best Practices (#3358)

* Add content to Frontend Best Practices

* Add content to frontend performance best practices
pull/3373/head
Kamran Ahmed 2 years ago committed by GitHub
parent e3adcdaba4
commit ff16ea542f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/best-practices/frontend-performance/content/analyse-stylesheets-complexity.md
  2. 14
      src/best-practices/frontend-performance/content/analyze-js-for-perf-issues.md
  3. 8
      src/best-practices/frontend-performance/content/avoid-404-files.md
  4. 21
      src/best-practices/frontend-performance/content/avoid-base64-images.md
  5. 10
      src/best-practices/frontend-performance/content/avoid-inline-css.md
  6. 10
      src/best-practices/frontend-performance/content/avoid-multiple-inline-js-snippets.md
  7. 4
      src/best-practices/frontend-performance/content/bundlephobia.md
  8. 13
      src/best-practices/frontend-performance/content/check-dependency-size.md
  9. 13
      src/best-practices/frontend-performance/content/choose-image-format-approprietly.md
  10. 16
      src/best-practices/frontend-performance/content/chrome-dev-tools.md
  11. 20
      src/best-practices/frontend-performance/content/compress-your-images.md
  12. 12
      src/best-practices/frontend-performance/content/concatenate-css-single-file.md
  13. 12
      src/best-practices/frontend-performance/content/cookie-size-less-4096-bytes.md
  14. 8
      src/best-practices/frontend-performance/content/enable-compression.md
  15. 19
      src/best-practices/frontend-performance/content/framework-guides.md
  16. 14
      src/best-practices/frontend-performance/content/inline-critical-css.md
  17. 12
      src/best-practices/frontend-performance/content/keep-cookie-count-below-20.md
  18. 11
      src/best-practices/frontend-performance/content/keep-dependencies-up-to-date.md
  19. 9
      src/best-practices/frontend-performance/content/keep-ttfb-less-1-3s.md
  20. 8
      src/best-practices/frontend-performance/content/keep-web-font-under-300k.md
  21. 10
      src/best-practices/frontend-performance/content/lighthouse.md
  22. 16
      src/best-practices/frontend-performance/content/load-offscreen-images-lazily.md
  23. 13
      src/best-practices/frontend-performance/content/make-css-files-non-blocking.md
  24. 13
      src/best-practices/frontend-performance/content/minify-css.md
  25. 11
      src/best-practices/frontend-performance/content/minify-html.md
  26. 13
      src/best-practices/frontend-performance/content/minify-your-javascript.md
  27. 7
      src/best-practices/frontend-performance/content/minimize-http-requests.md
  28. 11
      src/best-practices/frontend-performance/content/page-load-time-below-3s.md
  29. 6
      src/best-practices/frontend-performance/content/page-speed-insights.md
  30. 10
      src/best-practices/frontend-performance/content/page-weight-below-1500.md
  31. 10
      src/best-practices/frontend-performance/content/pre-load-urls-where-possible.md
  32. 6
      src/best-practices/frontend-performance/content/prefer-vector-images.md
  33. 7
      src/best-practices/frontend-performance/content/prevent-flash-text.md
  34. 91
      src/best-practices/frontend-performance/content/recommended-guides.md
  35. 11
      src/best-practices/frontend-performance/content/remove-unused-css.md
  36. 11
      src/best-practices/frontend-performance/content/serve-exact-size-images.md
  37. 6
      src/best-practices/frontend-performance/content/set-width-height-images.md
  38. 6
      src/best-practices/frontend-performance/content/squoosh-ap.md
  39. 7
      src/best-practices/frontend-performance/content/use-cdn.md
  40. 6
      src/best-practices/frontend-performance/content/use-http-cache-headers.md
  41. 10
      src/best-practices/frontend-performance/content/use-https-on-your-website.md
  42. 21
      src/best-practices/frontend-performance/content/use-non-blocking-javascript.md
  43. 18
      src/best-practices/frontend-performance/content/use-preconnect-to-load-fonts.md
  44. 4
      src/best-practices/frontend-performance/content/use-same-protocol.md
  45. 9
      src/best-practices/frontend-performance/content/use-service-workers-for-caching.md
  46. 12
      src/best-practices/frontend-performance/content/use-woff2-font-format.md
  47. 4
      src/best-practices/frontend-performance/content/web-page-test.md
  48. 2
      src/components/TopicOverlay/TopicOverlay.astro
  49. 15
      tailwind.config.cjs

@ -1 +1,12 @@
# Analyse stylesheets complexity
# Stylesheet Complexity
> Analyzing your stylesheets can help you to flag issues, redundancies and duplicate CSS selectors.
Sometimes you may have redundancies or validation errors in your CSS, analysing your CSS files and removed these complexities can help you to speed up your CSS files (because your browser will read them faster).
Your CSS should be organized, using a CSS preprocessor can help you with that. Some online tools listed below can also help you analysing and correct your code.
- [TestMyCSS | Optimize and Check CSS Performance](http://www.testmycss.com/)
- [CSS Stats](https://cssstats.com/)
- [macbre/analyze-css: CSS selectors complexity and performance analyzer](https://github.com/macbre/analyze-css)
- [Project Wallace](https://www.projectwallace.com/) is like CSS Stats but stores stats over time so you can track your changes

@ -1 +1,13 @@
# Analyze js for perf issues
# JavaScript Performance
> Check for performance problems in your JavaScript files (and CSS too)
JavaScript complexity can slow down runtime performance. Identifying these possible issues are essential to offer the smoothest user experience.
Use the Timeline tool in the Chrome Developer Tool to evaluate scripts events and found the one that may take too much time.
- [Speed Up JavaScript Execution | Tools for Web Developers](https://developers.google.com/web/tools/chrome-devtools/rendering-tools/js-execution)
- [JavaScript Profiling With The Chrome Developer Tools](https://www.smashingmagazine.com/2012/06/javascript-profiling-chrome-developer-tools/)
- [How to Record Heap Snapshots | Tools for Web Developers](https://developers.google.com/web/tools/chrome-devtools/memory-problems/heap-snapshots)
- [Chapter 22 - Profiling the Frontend - Blackfire](https://blackfire.io/docs/book/22-frontend-profiling)
- [30 Tips To Improve Javascript Performance](http://www.monitis.com/blog/30-tips-to-improve-javascript-performance/)

@ -1 +1,7 @@
# Avoid 404 files
# Serve Reachable Files
> Avoid requesting unreachable files (404)
404 request can slow down the performance of your website and negatively impact the user experience. Additionally, they can also cause search engines to crawl and index non-existent pages, which can negatively impact your search engine rankings. To avoid 404 requests, ensure that all links on your website are valid and that any broken links are fixed promptly.
- [How to avoid Bad Requests?](https://varvy.com/pagespeed/avoid-bad-requests.html)

@ -1 +1,20 @@
# Avoid base64 images
# Avoid Base64 Images
> You could eventually convert tiny images to base64 but it's actually not the best practice.
Using Base64 encoded images in your frontend can have several drawbacks.
First, Base64 encoded images are larger in size than their binary counterparts, which can slow down the loading time of your website.
Second, because Base64 encoded images are embedded directly in the HTML or CSS, they are included in the initial page load, which can cause delays for users with slower internet connections.
Third, Base64 encoded images do not benefit from browser caching, as they are part of the HTML or CSS and not a separate resource. So, every time the page is loaded, the images will be re-downloaded, even if the user has visited the page before.
Fourth, Base64 encoded images are not compatible with some old browser versions.
Instead of using Base64 encoded images, it is generally recommended to use binary image files and reference them using an img tag in HTML, with a standard src attribute. This allows the browser to cache the image and use it for subsequent page loads, resulting in faster loading times and better user experience.
- [Base64 Encoding & Performance, Part 1 and 2 by Harry Roberts](https://csswizardry.com/2017/02/base64-encoding-and-performance/)
- [A closer look at Base64 image performance – The Page Not Found Blog](http://www.andygup.net/a-closer-look-at-base64-image-performance/)
- [When to base64 encode images (and when not to) | David Calhoun](https://www.davidbcalhoun.com/2011/when-to-base64-encode-images-and-when-not-to/)
- [Base64 encoding images for faster pages | Performance and seo factors](https://varvy.com/pagespeed/base64-images.html)

@ -1 +1,9 @@
# Avoid inline css
# Avoid Inline CSS
> Avoid using embed or inline CSS inside your `<body>` (Not valid for HTTP/2)
One of the first reason it's because it's a good practice to separate content from design. It also helps you have a more maintainable code and keep your site accessible. But regarding performance, it's simply because it decreases the file-size of your HTML pages and the load time.
Always use external stylesheets or embed CSS in your `<head>` (and follow the others CSS performance rules)
- [Observe CSS Best Practices: Avoid CSS Inline Styles](https://www.lifewire.com/avoid-inline-styles-for-css-3466846)

@ -1 +1,9 @@
# Avoid multiple inline js snippets
# Avoid Inline JavaScript
> Avoid having multiple JavaScript codes embedded in the middle of your body. Regroup your JavaScript code inside external files or eventually in the `<head>` or at the end of your page (before `</body>`).
Placing JavaScript embedded code directly in your `<body>` can slow down your page because it loads while the DOM is being built. The best option is to use external files with async or defer to avoid blocking the DOM. Another option is to place some scripts inside your `<head>`. Most of the time analytics code or small script that need to load before the DOM gets to main processing.
Ensure that all your files are loaded using `async` or `defer` and decide wisely the code that you will need to inject in your `<head>`.
- [11 Tips to Optimize JavaScript and Improve Website Loading Speeds](https://www.upwork.com/hiring/development/11-tips-to-optimize-javascript-and-improve-website-loading-speeds/)

@ -1 +1,5 @@
# Bundlephobia
Bundlephobia is a website and npm package that allows developers to search for the size of any JavaScript package before adding it to their project. It provides information on the size of the package, as well as the size of its dependencies, to help developers make informed decisions about which packages to use and how they may impact the overall size of their application. Bundlephobia also offers badges which can be added to your GitHub README.md file to show the size of your package.
- [Official Website - Bundlephobia](https://bundlephobia.com/)

@ -1 +1,12 @@
# Check dependency size
# Check Dependency Size
> Ensure to use wisely external libraries, most of the time, you can use a lighter library for a same functionality.
You may be tempted to use one of the 745 000 packages you can find on npm, but you need to choose the best package for your needs. For example, MomentJS is an awesome library but with a lot of methods you may never use, that's why Day.js was created. It's just 2kB vs 16.4kB gz for Moment.
Always compare and choose the best and lighter library for your needs. You can also use tools like [npm trends](http://www.npmtrends.com/) to compare NPM package downloads counts or [Bundlephobia](https://bundlephobia.com/) to know the size of your dependencies.
- [ai/size-limit: Prevent JS libraries bloat](https://github.com/ai/size-limit)
- [webpack-bundle-analyzer - npm](https://www.npmjs.com/package/webpack-bundle-analyzer)
- [js-dependency-viewer - npm](https://www.npmjs.com/package/js-dependency-viewer)
- [Size Limit: Make the Web lighter](https://evilmartians.com/chronicles/size-limit-make-the-web-lighter)

@ -1 +1,12 @@
# Choose image format approprietly
# Image Format
> Choose your image format appropriately
To ensure that your images don't slow your website, choose the format that will correspond to your image. If it's a photo, JPEG is most of the time more appropriate than PNG or GIF. But don't forget to look a the nex-gen formats which can reduce the size of your files. Each image format has pros and cons, it's important to know these to make the best choice possible.
Use [Lighthouse](https://developers.google.com/web/tools/lighthouse/) to identify which images can eventually use next-gen formats (like JPEG 2000m JPEG XR or WebP). Compare different formats, sometimes using PNG8 is better than PNG16, sometimes it's not.
- [Serve Images in Next-Gen Formats](https://developers.google.com/web/tools/lighthouse/audits/webp)
- [What Is the Right Image Format for Your Website?](https://www.sitepoint.com/what-is-the-right-image-format-for-your-website/)
- [PNG8 - The Clear Winner](https://www.sitepoint.com/png8-the-clear-winner/)
- [8-bit vs 16-bit - What Color Depth You Should Use And Why It Matters](https://www.diyphotography.net/8-bit-vs-16-bit-color-depth-use-matters/)

@ -1 +1,15 @@
# Chrome dev tools
# Chrome DevTools
Chrome DevTools is a set of web development tools built into the Google Chrome browser. It allows developers to inspect and debug the front-end of web applications.
Some of the benefits of using Chrome DevTools include:
- Inspecting and editing HTML and CSS in real-time, which can be useful for identifying and fixing layout issues
- Debugging JavaScript code, including setting breakpoints, stepping through code, and examining the call stack
- Profiling the performance of web pages, including identifying slow-running JavaScript code and analyzing network requests
- Inspecting and debugging browser-side storage, including cookies, local storage, and indexedDB
- Auditing web pages for performance, accessibility, and best practices
Chrome DevTools are a powerful and essential tool for web developers, as it helps to improve debugging, testing, and optimization of the web application.
- [Chrome DevTools Docs](https://developer.chrome.com/docs/devtools/)

@ -1 +1,19 @@
# Compress your images
# Images Optimization
> Your images are optimized, compressed without direct impact to the end user.
Optimized images load faster in your browser and consume less data.
- Try using CSS3 effects when it's possible (instead of a small image
- When it's possible, use fonts instead of text encoded in your images
- Use SVG
- Use a tool and specify a level compression under 85.
- [Image Optimization](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/image-optimization)
- [Essential Image Optimization](https://images.guide/)
- [TinyJPG – Compress JPEG images intelligently](https://tinyjpg.com/)
- [Kraken.io - Online Image Optimizer](https://kraken.io/web-interface)
- [Compressor.io](https://compressor.io/compress)
- [Cloudinary - Image Analysis Tool](https://webspeedtest.cloudinary.com)
- [ImageEngine - Image Webpage Loading Test](https://demo.imgeng.in)
- [SVGOMG - Optimize SVG vector graphics files](https://jakearchibald.github.io/svgomg/)

@ -1 +1,11 @@
# Concatenate css single file
# CSS Concatenation
> CSS files are concatenated in a single file (Not always valid for HTTP/2)
If you are still using HTTP/1, you may need to still concatenate your files, it's less true if your server use HTTP/2 (tests should be made).
- Use online tool or any plugin before or during your build or your deployment to concatenate your files.
- Ensure, of course, that concatenation does not break your project
- [HTTP: Optimizing Application Delivery - High Performance Browser Networking (O'Reilly)](https://hpbn.co/optimizing-application-delivery/#optimizing-for-http2)
- [Performance Best Practices in the HTTP/2 Era](https://deliciousbrains.com/performance-best-practices-http2/)

@ -1 +1,11 @@
# Cookie size less 4096 bytes
# Cookie Size
> If you are using cookies, be sure each cookie doesn't exceed 4096 bytes and your domain name doesn't have more than 20 cookies.
Cookies are exchanged in the HTTP headers between web servers and browsers. It's important to keep the size of cookies as low as possible to minimize the impact on the user's response time.
- [Cookie specification: RFC 6265](https://tools.ietf.org/html/rfc6265)
- [Cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)
- [Browser Cookie Limits](http://browsercookielimits.squawky.net/)
- [Website Performance: Cookies Don't Taste So Good - Monitis Blog](http://www.monitis.com/blog/website-performance-cookies-dont-taste-so-good/)
- [Google's Web Performance Best Practices #3: Minimize Request Overhead - GlobalDots Blog](https://www.globaldots.com/googles-web-performance-best-practices-3-minimize-request-overhead/)

@ -1 +1,7 @@
# Enable compression
# Enable Compression
Use a compression method such as Gzip or Brotli to reduce the size of your JavaScript files. With a smaller sizes file, users will be able to download the asset faster, resulting in improved performance.
- [Check GZIP compression](https://checkgzipcompression.com/)
- [Check Brotli Compression](https://tools.keycdn.com/brotli-test)
- [Can I use... Brotli](https://caniuse.com/#feat=brotli)

@ -1 +1,18 @@
# Framework guides
# Framework Guides
These guides are intended to help you optimize your application for performance when using a specific framework.
## Angular
- [Angular Performance Checklist](https://github.com/mgechev/angular-performance-checklist)
## React
- [Optimizing Performance - React](https://reactjs.org/docs/optimizing-performance.html)
- [React image manipulation | Cloudinary](https://cloudinary.com/documentation/react_image_manipulation)
- [Debugging React performance with React 16 and Chrome Devtools.](https://building.calibreapp.com/debugging-react-performance-with-react-16-and-chrome-devtools-c90698a522ad)
- [Build Performant - React](https://web.dev/react/)
## Vue
- [Vue - Useful Links|Style Guide and Performance](https://learn-vuejs.github.io/vue-patterns/useful-links/)

@ -1 +1,13 @@
# Inline critical css
# Inline Critical CSS
> The CSS critical (or "above the fold") collects all the CSS used to render the visible portion of the page. It is embedded before your principal CSS call and between `<style></style>` in a single line (minified if possible).
Inlining critical CSS help to speed up the rendering of the web pages reducing the number of requests to the server.
Generate the CSS critical with online tools or using a plugin like the one that Addy Osmani developed.
- [Understanding Critical CSS](https://www.smashingmagazine.com/2015/08/understanding-critical-css/)
- [Critical by Addy Osmani on GitHub](https://github.com/addyosmani/critical) automates this.
- [Inlining critical CSS for better web performance | Go Make Things](https://gomakethings.com/inlining-critical-css-for-better-web-performance/)
- [Critical Path CSS Generator - Prioritize above the fold content :: SiteLocity](https://www.sitelocity.com/critical-path-css-generator)
- [Reduce the size of the above-the-fold content](https://developers.google.com/speed/docs/insights/PrioritizeVisibleContent)

@ -1 +1,11 @@
# Keep cookie count below 20
# Cookie Size
> If you are using cookies, be sure each cookie doesn't exceed 4096 bytes and your domain name doesn't have more than 20 cookies.
Cookies are exchanged in the HTTP headers between web servers and browsers. It's important to keep the size of cookies as low as possible to minimize the impact on the user's response time.
- [Cookie specification: RFC 6265](https://tools.ietf.org/html/rfc6265)
- [Cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)
- [Browser Cookie Limits](http://browsercookielimits.squawky.net/)
- [Website Performance: Cookies Don't Taste So Good - Monitis Blog](http://www.monitis.com/blog/website-performance-cookies-dont-taste-so-good/)
- [Google's Web Performance Best Practices #3: Minimize Request Overhead - GlobalDots Blog](https://www.globaldots.com/googles-web-performance-best-practices-3-minimize-request-overhead/)

@ -1 +1,10 @@
# Keep dependencies up to date
# Dependency Updates
> All JavaScript libraries used in your project are necessary (prefer Vanilla JavaScript for simple functionalities), updated to their latest version and don't overwhelm your JavaScript with unnecessary methods.
Most of the time, new versions come with optimization and security fix. You should use the most optimized code to speed up your project and ensure that you'll not slow down your website or app without outdated plugin.
If your project use NPM packages, [npm-check](https://www.npmjs.com/package/npm-check) is a pretty interesting library to upgrade / update your libraries. [Greenkeeper](https://greenkeeper.io/) can automatically look for your dependencies and suggest an update every time a new version is out.
- [Vanilla JavaScript for building powerful web applications](https://plainjs.com/)

@ -1 +1,8 @@
# Keep ttfb less 1 3s
# Keep TTFB < 1.3s
Reduce as much as you can the time your browser waits before receiving data.
- [What is Waiting (TTFB) in DevTools, and what to do about it](https://scaleyourcode.com/blog/article/27)
- [Monitoring your servers with free tools is easy](https://scaleyourcode.com/blog/article/7)
- [Time to First Byte (TTFB)](https://varvy.com/pagespeed/ttfb.html)
- [Global latency testing tool](https://latency.apex.sh)

@ -1 +1,7 @@
# Keep web font under 300k
# Keep Web Font Size Under 300kb
Web fonts are a great way to add style to your website. However, they can also be a major performance bottleneck. The more fonts you use, the more time it takes for the browser to download and render the page. This can lead to a poor user experience and a high bounce rate.
Webfont sizes shouldn't exceed 300kb (all variants included) and are optimized for performance.
- [Font Bytes - Page Weight](https://httparchive.org/reports/page-weight#bytesFont)

@ -1 +1,11 @@
# Lighthouse
Lighthouse is an open-source tool developed by Google that is used to audit the performance, accessibility, and SEO of web pages. It is available as a browser extension and as a command-line tool, and it can be run on any web page to generate a report with recommendations for improvement.
Lighthouse works by simulating the load and interaction of a web page and measuring various performance metrics, such as load time, time to first paint, and time to interactive. It also checks for common issues such as incorrect image sizes, missing alt text, and broken links.
Lighthouse provides a comprehensive and easy-to-use tool for identifying and fixing performance and accessibility issues on web pages. It is widely used by web developers and is integrated into many popular development tools.
Visit the following resources to learn more:
- [Lighthouse - Google Developers](https://developers.google.com/web/tools/lighthouse)

@ -1 +1,15 @@
# Load offscreen images lazily
# Lazy Loading
> Offscreen images are loaded lazily (A noscript fallback is always provided).
It will improve the response time of the current page and then avoid loading unnecessary images that the user may not need.
- Use Lighthouse to identify how many images are offscreen.
- Use a JavaScript plugin like the following to lazyload your images. Make sure you target offscreen images only.
- Also make sure to lazyload alternative images shown at mouseover or upon other user actions.
- [verlok/lazyload: GitHub](https://github.com/verlok/lazyload)
- [aFarkas/lazysizes: GitHub](https://github.com/aFarkas/lazysizes/)
- [mfranzke/loading-attribute-polyfill: GitHub](https://github.com/mfranzke/loading-attribute-polyfill/)
- [Lazy Loading Images and Video | Web Fundamentals | Google Developers](https://developers.google.com/web/fundamentals/performance/lazy-loading-guidance/images-and-video/)
- [5 Brilliant Ways to Lazy Load Images For Faster Page Loads - Dynamic Drive Blog](http://blog.dynamicdrive.com/5-brilliant-ways-to-lazy-load-images-for-faster-page-loads/)

@ -1 +1,12 @@
# Make css files non blocking
# Non-Blocking CSS
> CSS files need to be non-blocking to prevent the DOM from taking time to load.
CSS files can block the page load and delay the rendering of your page. Using `preload` can actually load the CSS files before the browser starts showing the content of the page.
You need to add the `rel` attribute with the preload value and add `as="style"` on the `<link>` element.
- [loadCSS by filament group](https://github.com/filamentgroup/loadCSS)
- [Example of preload CSS using loadCSS](https://gist.github.com/thedaviddias/c24763b82b9991e53928e66a0bafc9bf)
- [Preloading content with rel="preload"](https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content)
- [Preload: What Is It Good For? — Smashing Magazine](https://www.smashingmagazine.com/2016/02/preload-what-is-it-good-for/)

@ -1 +1,12 @@
# Minify css
# Minify CSS
> All CSS files are minified, comments, white spaces and new lines are removed from production files.
When CSS files are minified, the content is loaded faster and less data is sent to the client. It's important to always minify CSS files in production. It is beneficial for the user as it is for any business who wants to lower bandwidth costs and lower resource usage.
Use tools to minify your files automatically before or during your build or your deployment.
- [cssnano: A modular minifier based on the PostCSS ecosystem. - cssnano](https://cssnano.co/)
- [CSS Minfier](https://goonlinetools.com/css-minifier/)
- [@neutrinojs/style-minify - npm](https://www.npmjs.com/package/@neutrinojs/style-minify)
- [Online CSS Compressor](http://refresh-sf.com)

@ -1 +1,10 @@
# Minify html
# Minify HTML
> The HTML code is minified, comments, white spaces and new lines are removed from production files.
Removing all unnecessary spaces, comments and attributes will reduce the size of your HTML and speed up your site's page load times and obviously lighten the download for your user.
Most of the frameworks have plugins to facilitate the minification of the webpages. You can use a bunch of NPM modules that can do the job for you automatically.
- [HTML minifier | Minify Code](http://minifycode.com/html-minifier/)
- [Online HTML Compressor](http://refresh-sf.com)
- [Experimenting with HTML minifier — Perfection Kills](http://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype)

@ -1 +1,12 @@
# Minify your javascript
# Minify JavaScript
> All JavaScript files are minified, comments, white spaces and new lines are removed from production files (still valid if using HTTP/2).
Removing all unnecessary spaces, comments and break will reduce the size of your JavaScript files and speed up your site's page load times and obviously lighten the download for your user.
Use the tools suggested below to minify your files automatically before or during your build or your deployment.
- [terser - JavaScript parser, mangler and compressor toolkit for ES6+](https://github.com/terser/terser)
- [uglify-js - npm](https://www.npmjs.com/package/uglify-js)
- [Online JavaScript Compressor](http://refresh-sf.com)
- [Short read: How is HTTP/2 different? Should we still minify and concatenate?](https://scaleyourcode.com/blog/article/28)

@ -1 +1,6 @@
# Minimize http requests
# Minimize HTTP Requests
> Always ensure that every file requested are essential for your website or application.
- [Combine external CSS](https://varvy.com/pagespeed/combine-external-css.html)
- [Combine external JavaScript](https://varvy.com/pagespeed/combine-external-javascript.html)

@ -1 +1,10 @@
# Page load time below 3s
# Page Load Time
> Reduce as much as possible your page load times to quickly deliver your content to your users.
Faster your website or app is, less you have probability of bounce increases, in other terms you have less chances to lose your user or future client. Enough researches on the subject prove that point.
Use online tools like [Page Speed Insights](https://developers.google.com/speed/pagespeed/insights/) or [WebPageTest](https://www.webpagetest.org/) to analyze what could be slowing you down and use the Front-End Performance Checklist to improve your load times.
- [Compare your mobile site speed](https://www.thinkwithgoogle.com/feature/mobile/)
- [Test Your Mobile Website Speed and Performance - Think With Google](https://testmysite.thinkwithgoogle.com/intl/en-us)
- [Average Page Load Times for 2018 - How does yours compare? - MachMetrics Speed Blog](https://www.machmetrics.com/speed-blog/average-page-load-times-websites-2018/)

@ -1 +1,5 @@
# Page speed insights
# Page Speed Insights
Page Speed Insights is a free tool from Google that analyzes the performance of a web page and provides suggestions for improvements.
- [Page Speed Insights](https://pagespeed.web.dev/)

@ -1 +1,11 @@
# Page weight below 1500
> Reduce the size of your page + resources as much as you can.
Ideally you should try to target < 500 KB but the state of web shows that the median of Kilobytes is around 1500 KB (even on mobile). Depending on your target users, network connection, devices, it's important to reduce as much as possible your total Kilobytes to have the best user experience possible.
All the listed best practices in this list will help you to reduce as much as possible your resources and your code.
- [Page Weight](https://httparchive.org/reports/page-weight#bytesTotal)
- [What Does My Site Cost?](https://whatdoesmysitecost.com/)
- [web - Measure full page size in Chrome DevTools - Stack Overflow](https://stackoverflow.com/questions/38239980/measure-full-page-size-in-chrome-devtools)

@ -1 +1,9 @@
# Pre load urls where possible
# Preload URLs
> Popular browsers can use directive on `<link>` tag and `"rel"` attribute with certain keywords to pre-load specific URLs
Prefetching allows a browser to silently fetch the necessary resources needed to display content that a user might access in the near future. The browser is able to store these resources in its cache and speed up the way web pages load when they are using different domains for page resources. When a web page has finished loading and the idle time has passed, the browser begins downloading other resources. When a user go in a particular link (already prefetched), the content will be instantly served.
- [What Is Prefetching and Why Use It](https://www.keycdn.com/support/prefetching)
- [Prefetching, preloading, prebrowsing](https://css-tricks.com/prefetching-preloading-prebrowsing/)
- [What is Preload, Prefetch, and Preconnect](https://www.keycdn.com/blog/resource-hints)

@ -1 +1,5 @@
# Prefer vector images
# Prefer Vector Images
> Prefer using vector image rather than bitmap images (when possible).
Vector images (SVG) tend to be smaller than images and SVG's are responsive and scale perfectly. These images can be animated and modified by CSS.

@ -1 +1,6 @@
# Prevent flash text
# Prevent Flash Text
> Avoid transparent text until the Webfont is loaded
- [`font-display` for the Masses](https://css-tricks.com/font-display-masses/)
- [CSS font-display: The Future of Font Rendering on the Web](https://www.sitepoint.com/css-font-display-future-font-rendering-web/)

@ -1 +1,90 @@
# Recommended guides
# Recommended Guides
> Optimize the critical rendering path:
* [Critical CSS? Not So Fast!](https://csswizardry.com/2022/09/critical-css-not-so-fast/)
* [Priority Hints - What Your Browser Doesn’t Know (Yet)](https://www.etsy.com/codeascraft/priority-hints-what-your-browser-doesnt-know-yet)
* [Optimizing resource loading with Priority Hints](https://web.dev/priority-hints/)
* [Chrome Resource Priorities and Scheduling](https://docs.google.com/document/d/1bCDuq9H1ih9iNjgzyAL0gpwNFiEP4TZS-YLRp_RuMlc/edit?usp=sharing)
* [How To Optimize CSS for Peak Site Performance](https://kinsta.com/blog/optimize-css/)
* [Eliminate render blocking CSS to improve start render time](https://www.jeffreyknox.dev/blog/eliminate-render-blocking-css-to-improve-start-render-time/)
* [Small Bundles, Fast Pages: What To Do With Too Much JavaScript](https://calibreapp.com/blog/bundle-size-optimization)
* [How to Eliminate Render-Blocking Resources: a Deep Dive](https://sia.codes/posts/render-blocking-resources/)
* [The Critical Request: How to Prioritise Requests to Improve Speed](https://calibreapp.com/blog/critical-request)
* [How to Improve CSS Performance](https://calibreapp.com/blog/css-performance)
* [The Simplest Way to Load CSS Asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/)
* [CSS audit](https://css-tricks.com/a-quick-css-audit-and-general-notes-about-design-systems/)
* [Measuring the Critical Rendering Path](https://developers.google.com/web/fundamentals/performance/critical-rendering-path/measure-crp)
* [Inlining or Caching? Both Please!](https://www.filamentgroup.com/lab/inlining-cache.html)
* [CSS and Network Performance](https://csswizardry.com/2018/11/css-and-network-performance/)
* [Analyzing Critical Rendering Path Performance](https://developers.google.com/web/fundamentals/performance/critical-rendering-path/analyzing-crp)
* [Front-End Performance Checklist](https://github.com/thedaviddias/Front-End-Performance-Checklist)
* [The PRPL Pattern](https://developers.google.com/web/fundamentals/performance/prpl-pattern/)
* [Now You See Me: How To Defer, Lazy-Load And Act With IntersectionObserver](https://www.smashingmagazine.com/2018/01/deferring-lazy-loading-intersection-observer-api/)
* [Optimising the front end for the browser](https://hackernoon.com/optimising-the-front-end-for-the-browser-f2f51a29c572)
* [Prefer DEFER Over ASYNC](https://calendar.perfplanet.com/2016/prefer-defer-over-async/)
* [A comprehensive guide to font loading strategies](https://www.zachleat.com/web/comprehensive-webfonts/)
* [Understanding the critical rendering path, rendering pages in 1 second](https://medium.com/@luisvieira_gmr/understanding-the-critical-rendering-path-rendering-pages-in-1-second-735c6e45b47a)
* [More Weight Doesn’t Mean More Wait](https://www.filamentgroup.com/lab/weight-wait.html)
> JavaScript Rendering Performance
* [Five Data-Loading Patterns To Boost Web Performance](https://www.smashingmagazine.com/2022/09/data-loading-patterns-improve-frontend-performance/)
* [Optimize long tasks](https://web.dev/optimize-long-tasks/)
* [The impact of removing jQuery on our web performance](https://insidegovuk.blog.gov.uk/2022/08/15/the-impact-of-removing-jquery-on-our-web-performance/)
* [Profiling & Optimizing the runtime performance with the DevTools Performance tab](iamtk.co/profiling-and-optimizing-the-runtime-performance-with-the-devtools-performance-tab)
* [Don't fight the browser preload scanner](https://web.dev/preload-scanner/)
* [The Web Performance impact of jQuery](https://twitter.com/TheRealNooshu/status/1509487050122276864)
* [Have Single-Page Apps Ruined the Web? | Transitional Apps](https://www.youtube.com/watch?v=860d8usGC0o)
* [Improve how you architect webapps](https://www.patterns.dev/)
* [Nuxt SSR Optimizing Tips](https://vueschool.io/articles/vuejs-tutorials/nuxt-ssr-optimizing-tips/, Filip Rakowski
* [GPU accelerated JavaScript](https://gpu.rocks/#/)
* [Introducing Partytown 🎉: Run Third-Party Scripts From a Web Worker](https://dev.to/adamdbradley/introducing-partytown-run-third-party-scripts-from-a-web-worker-2cnp)
* [Astro: Astro is a fresh but familiar approach to building websites. Astro combines decades of proven performance best practices with the DX improvements of the component-oriented era. Use your favorite JavaScript framework and automatically ship the bare-minimum amount of JavaScript—by default.](https://docs.astro.build/getting-started/)
* [Minimising Layout and Layout thrashing for 60 FPS](https://www.charistheo.io/blog/2021/09/dom-reflow-and-layout-thrashing/)
* [Does shadow DOM improve style performance?](https://nolanlawson.com/2021/08/15/does-shadow-dom-improve-style-performance/)
* [Debugging memory leaks - HTTP 203](https://www.youtube.com/watch?v=YDU_3WdfkxA)
* [Explore JavaScript Dependencies With Lighthouse Treemap](https://sia.codes/posts/lighthouse-treemap/)
* [The real cost of Javascript dependencies (and the state of JS package quality)](https://medium.com/voodoo-engineering/the-real-cost-of-javascript-dependencies-and-the-state-of-js-package-quality-a8dacd74c0ec)
* [The State Of Web Workers In 2021](https://www.smashingmagazine.com/2021/06/web-workers-2021/)
* [Techniques for developing high-performance animations](https://web.dev/animations/)
* [Building a Faster Web Experience with the postTask Scheduler](https://medium.com/airbnb-engineering/building-a-faster-web-experience-with-the-posttask-scheduler-276b83454e91), Callie (Airbnb Engineering & Data Science)
* [Don’t attach tooltips to document.body – Learn how the browser works – Debug forced reflow](https://atfzl.com/don-t-attach-tooltips-to-document-body)
* [How to Create and Fix Memory Leaks With Chrome DevTools](https://betterprogramming.pub/build-me-an-angular-app-with-memory-leaks-please-36302184e658)
* [JavaScript performance beyond bundle size](https://nolanlawson.com/2021/02/23/javascript-performance-beyond-bundle-size/)
* [The Import On Interaction Pattern](https://addyosmani.com/blog/import-on-interaction/)
* [The “Live DOM” Is Not “Slow”, “Bad”, Or “Wrong”. Web Developers Are.](https://levelup.gitconnected.com/the-live-dom-is-not-slow-bad-or-wrong-web-developers-are-2bf86c3b9e2e)
* [Prevent layout shifts with CSS grid stacks](https://www.hsablonniere.com/prevent-layout-shifts-with-css-grid-stacks--qcj5jo/)
* [content-visibility: the new CSS property that boosts your rendering performance](https://web.dev/content-visibility/)
* [Preact vs React - Updating React at Etsy](https://github.com/mq2thez/blog/blob/main/upgrade-react-etsy/preact-vs-react.md)
* [The Cost of Javascript Frameworks](https://timkadlec.com/remembers/2020-04-21-the-cost-of-javascript-frameworks/)
* [Fixing memory leaks in web applications](https://nolanlawson.com/2020/02/19/fixing-memory-leaks-in-web-applications/)
* [How to load polyfills only when needed](https://3perf.com/blog/polyfills/)
* [Responsible JavaScript: Part III - Third parties](https://alistapart.com/article/responsible-javascript-part-3/)
* [The cost of JavaScript in 2019](https://v8.dev/blog/cost-of-javascript-2019)
* [When should you be using Web Workers?](https://dassur.ma/things/when-workers/)
* [Responsible Javascript: Part II - Code Bundle](https://alistapart.com/article/responsible-javascript-part-2/)
* [Faster script loading with BinaryAST?](https://blog.cloudflare.com/binary-ast/)
* [Svelte 3: Rethinking reactivity](https://svelte.dev/blog/svelte-3-rethinking-reactivity)
* [Responsible Javascript: Part I - Web platform over frameworks](https://alistapart.com/article/responsible-javascript-part-1/)
* [JavaScript Loading Priorities in Chrome](https://addyosmani.com/blog/script-priorities/)
* [Idle Until Urgent](https://philipwalton.com/articles/idle-until-urgent/)
* [Browser painting and considerations for web performance](https://css-tricks.com/browser-painting-and-considerations-for-web-performance/)
* [The Cost Of JavaScript In 2018](https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4) ([Video](https://www.youtube.com/watch?v=i5R7giitymk))
* [Examining Web Worker Performance](https://www.loxodrome.io/post/web-worker-performance/)
* [Front-End Performance Checklist](https://github.com/thedaviddias/Front-End-Performance-Checklist)
* [jankfree](http://jankfree.org/)
* [What forces layout/reflow?](https://gist.github.com/paulirish/5d52fb081b3570c81e3a)
* [Using requestIdleCallback](https://developers.google.com/web/updates/2015/08/using-requestidlecallback)
* [Optimize Javascript Execution](https://developers.google.com/web/fundamentals/performance/rendering/optimize-javascript-execution)
* [Why Web Developers Need to Care about Interactivity](https://philipwalton.com/articles/why-web-developers-need-to-care-about-interactivity/)
* [Improving Performance with the Paint Timing API](https://www.sitepen.com/blog/2017/10/06/improving-performance-with-the-paint-timing-api)
* [Deploying ES2015+ Code in Production Today](https://philipwalton.com/articles/deploying-es2015-code-in-production-today/)
* [Performant Web Animations and Interactions: Achieving 60 FPS](https://blog.algolia.com/performant-web-animations/)
* [JavaScript Start-up Performance](https://medium.com/reloading/javascript-start-up-performance-69200f43b201)
* [Performant Parallaxing](https://developers.google.com/web/updates/2016/12/performant-parallaxing)
* [The Anatomy of a Frame](https://aerotwist.com/blog/the-anatomy-of-a-frame/)
* [The future of loading CSS](https://jakearchibald.com/2016/link-in-body/)
* [4 Types of Memory Leaks in JavaScript and How to Get Rid Of Them](https://auth0.com/blog/four-types-of-leaks-in-your-javascript-code-and-how-to-get-rid-of-them/)
* [The cost of frameworks](https://aerotwist.com/blog/the-cost-of-frameworks/)
* [FLIP Your Animations](https://aerotwist.com/blog/flip-your-animations/)

@ -1 +1,10 @@
# Remove unused css
# Remove Unused CSS
Removing unused CSS selectors can reduce the size of your files and then speed up the load of your assets.
Always check if the framework CSS you want to use don't already has a reset / normalize code included. Sometimes you may not need everything that is inside your reset / normalize file.
- [UnCSS Online](https://uncss-online.com/)
- [PurifyCSS](https://github.com/purifycss/purifycss)
- [PurgeCSS](https://github.com/FullHuman/purgecss)
- [Chrome DevTools Coverage](https://developers.google.com/web/updates/2017/04/devtools-release-notes#coverage)

@ -1 +1,10 @@
# Serve exact size images
# Responsive Images
> Ensure to serve images that are close to your display size.
Small devices don't need images bigger than their viewport. It's recommended to have multiple versions of one image on different sizes.
- Create different image sizes for the devices you want to target
- Use `srcset` and `picture` to deliver multiple variants of each image.
- [Responsive images - Learn web development | MDN](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)

@ -1 +1,5 @@
# Set width height images
# Image Dimensions
> Set width and height attributes on `<img>` if the final rendered image size is known.
If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the images load).

@ -1 +1,5 @@
# Squoosh ap
# Squoosh.app
Squoosh.app is a web app that allows you to compress images using a variety of codecs. It is built by Google Chrome team and is open source.
- [Squoosh.app](https://squoosh.app/)

@ -1 +1,6 @@
# Use cdn
# Use CDN
Use a CDN to serve your static assets. This will reduce the load on your server and improve the performance of your site.
- [10 Tips to Optimize CDN Performance - CDN Planet](https://www.cdnplanet.com/blog/10-tips-optimize-cdn-performance/)
- [HTTP Caching | Web Fundamentals | Google Developers](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching)

@ -1 +1,5 @@
# Use http cache headers
# HTTP Caching
Set HTTP headers to avoid expensive number of roundtrips between your browser and the server.
- [Using cache-control for browser caching](https://varvy.com/pagespeed/cache-control.html)

@ -1 +1,9 @@
# Use https on your website
# Use HTTPs
HTTPS is not only for ecommerce websites, but for all websites that are exchanging data. Data shared by a user or data shared to an external entity. Modern browsers today limit functionalities for sites that are not secure. For example: geolocation, push notifications and service workers don't work if your instance is not using HTTPS. And today is much more easy to setup a project with an SSL certificate than it was before (and for free, thanks to Let's Encrypt).
- [Why Use HTTPS? | Cloudflare](https://www.cloudflare.com/learning/security/why-use-https/)
- [Enabling HTTPS Without Sacrificing Your Web Performance - Moz](https://moz.com/blog/enabling-https-without-sacrificing-web-performance)
- [How HTTPS Affects Website Performance](https://wp-rocket.me/blog/https-affects-website-performance/)
- [HTTP versus HTTPS versus HTTP2 - The real story | Tune The Web](https://www.tunetheweb.com/blog/http-versus-https-versus-http2/)
- [HTTP vs HTTPS — Test them both yourself](https://www.httpvshttps.com/)

@ -1 +1,20 @@
# Use non blocking javascript
# Non-Blocking JavaScript
JavaScript files are loaded asynchronously using async or deferred using defer attribute.
```javascript
<!-- Defer Attribute -->
<script defer src="foo.js"></script>
<!-- Async Attribute -->
<script async src="foo.js"></script>
```
JavaScript blocks the normal parsing of the HTML document, so when the parser reaches a `<script>` tag (particularly is inside the `<head>`), it stops to fetch and run it. Adding async or defer are highly recommended if your scripts are placed in the top of your page but less valuable if just before your `</body>` tag. But it's a good practice to always use these attributes to avoid any performance issue.
- Add `async` (if the script don't rely on other scripts) or `defer` (if the script relies upon or relied upon by an async script) as an attribute to your script tag.
- If you have small scripts, maybe use inline script place above async scripts.
- [Remove Render-Blocking JavaScript](https://developers.google.com/speed/docs/insights/BlockingJS)
- [Defer loading JavaScript](https://varvy.com/pagespeed/defer-loading-javascript.html)

@ -1 +1,17 @@
# Use preconnect to load fonts
# Preconnect on Fonts
```html
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
```
When you arrived on a website, your device needs to find out where your site lives and which server it needs to connect with. Your browser had to contact a DNS server and wait for the lookup complete before fetching the resource (fonts, CSS files...). Prefetches and preconnects allow the browser to lookup the DNS information and start establishing a TCP connection to the server hosting the font file. This provides a performance boost because by the time the browser gets around to parsing the css file with the font information and discovering it needs to request a font file from the server, it will already have pre-resolved the DNS information and have an open connection to the server ready in its connection pool.
- Before prefetching your webfonts, use webpagetest to evaluate your website
- Look for teal colored DNS lookups and note the host that are being requested
- Prefetch your webfonts in your `<head>` and add eventually these hostnames that you should prefetch too
- [Faster Google Fonts with Preconnect - CDN Planet](https://www.cdnplanet.com/blog/faster-google-webfonts-preconnect/)
- [Make Your Site Faster with Preconnect Hints | Viget](https://www.viget.com/articles/make-your-site-faster-with-preconnect-hints/)
- [Ultimate Guide to Browser Hints: Preload, Prefetch, and Preconnect - MachMetrics Speed Blog](https://www.machmetrics.com/speed-blog/guide-to-browser-hints-preload-preconnect-prefetch/)
- [A Comprehensive Guide to Font Loading Strategies—zachleat.com](https://www.zachleat.com/web/comprehensive-webfonts/#font-face)
- [typekit/webfontloader: Web Font Loader gives you added control when using linked fonts via @font-face.](https://github.com/typekit/webfontloader)

@ -1 +1,3 @@
# Use same protocol
# Use same Protocol
Avoid having your website serving files coming from source using HTTP on your website which is using HTTPS for example. If your website is using HTTPS, external files should come from the same protocol.

@ -1 +1,8 @@
# Use service workers for caching
# Use Service Workers
You are using Service Workers in your PWA to cache data or execute possible heavy tasks without impacting the user experience of your application.
- [Service Workers: an Introduction | Web Fundamentals | Google Developers](https://developers.google.com/web/fundamentals/primers/service-workers/)
- [Measuring the Real-world Performance Impact of Service Workers | Web | Google Developers](https://developers.google.com/web/showcase/2016/service-worker-perf)
- [What Are Service Workers and How They Help Improve Performance](https://www.keycdn.com/blog/service-workers/)
- [How does a service worker work? - YouTube](https://www.youtube.com/watch?v=__xAtWgfzvc)

@ -1 +1,11 @@
# Use woff2 font format
# Use WOFF 2.0 Web Font
According to Google, the WOFF 2.0 Web Font compression format offers 30% average gain over WOFF 1.0. It's then good to use WOFF 2.0, WOFF 1.0 as a fallback and TTF.
Check before buying your new font that the provider gives you the WOFF2 format. If you are using a free font, you can always use Font Squirrel to generate all the formats you need.
- [WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2](https://gist.github.com/sergejmueller/cf6b4f2133bcb3e2f64a)
- [Create Your Own @font-face Kits » Font Squirrel](https://www.fontsquirrel.com/tools/webfont-generator)
- [IcoMoon App - Icon Font, SVG, PDF & PNG Generator](https://icomoon.io/app/)
- [Using @font-face | CSS-Tricks](https://css-tricks.com/snippets/css/using-font-face/?ref=frontendchecklist)
- [Can I use... WOFF2](https://caniuse.com/#feat=woff2)

@ -1 +1,3 @@
# Web page test
# webpagetest.org
Webpagetest.org is a website performance testing tool that allows users to test the load time and performance of web pages. It provides a wealth of information about the page load, including load time, Speed Index, and filmstrip view of the page load, as well as a breakdown of the page components and their load times. It also allows for testing from multiple locations and browsers. The test results can be shared and compared with others. It is widely used by developers, marketers, and website owners to improve the performance and user experience of their websites.

@ -47,7 +47,7 @@ const { contentContributionLink } = Astro.props;
<div
id='topic-content'
class='prose prose-h1:mt-7 prose-h1:mb-2.5 prose-p:mt-0 prose-p:mb-2 prose-li:m-0 prose-li:mb-0.5 prose-h2:mb-3 prose-h2:mt-0 prose-h3:mt-[10px] prose-h3:mb-[5px]'
class='prose prose-blockquote:not-italic prose-blockquote:text-gray-700 prose-quoteless prose-blockquote:font-normal prose-h1:mt-7 prose-h1:mb-2.5 prose-p:mt-0 prose-p:mb-2 prose-li:m-0 prose-li:mb-0.5 prose-h2:mb-3 prose-h2:mt-0 prose-h3:mt-[10px] prose-h3:mb-[5px]'
>
</div>

@ -1,11 +1,20 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue,svg}"],
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue,svg}'],
theme: {
extend: {},
extend: {
typography: {
quoteless: {
css: {
'blockquote p:first-of-type::before': { content: 'none' },
'blockquote p:first-of-type::after': { content: 'none' },
},
},
},
},
container: {
center: true,
},
},
plugins: [require("@tailwindcss/typography")],
plugins: [require('@tailwindcss/typography')],
};

Loading…
Cancel
Save