#Reduce JavaScript execution time 2.1 sConsider reducing the time spent parsing, compiling, and exe

4 messages · Page 1 of 1 (latest)

fast oriole
#

Google Page Speed said:

Reduce JavaScript execution time 2.1 s
Consider reducing the time spent parsing, compiling, and executing JS. You may find delivering smaller JS payloads helps with this. Learn how to reduce Javascript execution time.

URL
Total CPU Time
Script Evaluation
Script Parse
Google Tag Manager Tag-Manager
1,212 ms 1,128 ms 73 ms
/gtag/js?id=G-V002PYFD20(www.googletagmanager.com)
790 ms
752 ms
30 ms
/gtag/js?id=AW-835…&l=dataLayer&cx=c(www.googletagmanager.com)
343 ms
320 ms
21 ms
/gtm.js?id=GTM-T78HP5G(www.googletagmanager.com)
79 ms
56 ms
22 ms
fitoag.com.br 1st Party
789 ms 320 ms 10 ms
/geral/(lp.fitoag.com.br)
494 ms
44 ms
9 ms
/_astro/index.DaIM70HK.js(lp.fitoag.com.b

pulsar sparrowBOT
#

Hi @fast oriole. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Astro is designed to help you reduce JavaScript execution time by minimizing the amount of JavaScript sent to the browser. Here are some strategies you can use:

  1. Minimize JavaScript Usage: Astro encourages minimal JavaScript usage. By using less JavaScript, you reduce the amount of processing power a user's device needs to load and render pages. This can significantly reduce the time spent parsing, compiling, and executing JS (source (https://starlight.astro.build/environmental-impact/#power-consumption)).

  2. Use Astro Islands: Astro Islands is a feature that allows you to convert the majority of your website to fast, static HTML, and only load JavaScript for the individual components that need it. This can significantly reduce the amount of JavaScript that needs to be parsed and executed (source (https://docs.astro.build/en/concepts/islands/#what-are-the-benefits-of-islands)).

  3. Optimize JavaScript Loading: Astro allows you to control how and when each component is rendered. For example, you can tell Astro to only load a component when it becomes visible on the page. This can help reduce the amount of JavaScript that needs to be loaded and executed at once (source (https://docs.astro.build/en/concepts/islands/#what-are-the-benefits-of-islands)).

  4. Use Lightweight Analytics: If you're using analytics tracking scripts, consider choosing a lightweight option like Cabin, Fathom, or Plausible. These scripts are less JavaScript-heavy and can help reduce the total amount of JavaScript that needs to be executed (source (https://starlight.astro.build/environmental-impact/#power-consumption)).

#
  1. Lazy Load Videos: If you're using video embeds, consider improving their performance by waiting to load the video until the user interacts with it. This can help reduce the amount of JavaScript that needs to be executed (source (https://starlight.astro.build/environmental-impact/#power-consumption)).

Remember, parsing and compiling JavaScript is one of the most expensive tasks browsers have to do. By reducing the amount of JavaScript used in your Astro project, you can significantly reduce JavaScript execution time and improve your website's performance.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: