freecourses.digital
Lesson progress: 0 of 3 activities done
All lessons in Technical SEO Auditing Lesson 7.5 of 84

JavaScript and CSS Performance

In this lesson

  • How CSS and JavaScript block rendering
  • How unused code and long tasks affect LCP and INP
  • How to measure third-party script impact
  • Which fixes to recommend to developers

Short answer

JavaScript and CSS slow pages when they block rendering, ship unused code, or run long tasks on the main thread. Audit them with Lighthouse diagnostics for render-blocking resources, unused CSS and JavaScript, total blocking time, and third-party impact, then recommend deferring scripts, removing unused code, and limiting heavy third-party tags.

A Quezon City clinic’s site loaded 41 JavaScript files: a page builder, two sliders, a chat widget, three analytics tags, a pop-up tool, and a booking plugin used on only one page. On a mid-range Android phone, tapping the menu took nearly a second to respond.

How CSS and JavaScript slow pages

  • Render blocking: CSS and synchronous scripts in the head delay first paint and LCP.
  • Unused code: whole libraries loaded for one feature, or every plugin’s files loaded on every page.
  • Long tasks: heavy scripts keep the main thread busy, so taps wait. This hurts INP.
  • Third parties: chat, ads, heatmaps, and social embeds often cost more than your own code.

What to check

In Lighthouse (PageSpeed Insights lab section), review:

  1. Eliminate render-blocking resources
  2. Reduce unused JavaScript and unused CSS
  3. Total Blocking Time and long main-thread tasks
  4. Reduce the impact of third-party code
  5. Minify CSS and JavaScript

Repeat on each template, since plugins often load per page type.

Recommendations developers can act on

  • Add defer to non-critical scripts.
  • Inline critical CSS, load the rest asynchronously.
  • Load plugin files only on pages that use them.
  • Break up long tasks and delay non-essential widgets until user interaction.
  • Remove unused tags from Tag Manager.

Practice: what does this mainly hurt?

Sort each item into the right group.

  • Large CSS file blocking first paint

  • Chat widget running long tasks on every tap

  • Synchronous script in the head

  • Heavy menu JavaScript on click

  • Analytics tags firing complex code after each interaction

Common mistakes

  • Recommending “remove all JavaScript.” Be specific.
  • Ignoring Tag Manager. Old tags pile up for years.
  • Testing only on fast desktops.
1. What does defer do?
2. Long main-thread tasks mostly hurt...
3. A booking plugin loads on every page but is used on one. Fix?

Your action

Next, you will check mobile usability and responsive rendering.

Key terms

Render-blocking resource
A CSS or JavaScript file the browser must download and process before showing the page.
Main thread
The browser thread that runs JavaScript, layout, and painting. When it is busy, the page cannot respond.
Long task
Any main-thread task over 50 milliseconds, a common cause of poor INP.
Third-party script
Code loaded from another company, such as chat widgets, analytics, ad tags, and social embeds.

Questions beginners ask

What does defer do?

It downloads a script without blocking rendering and runs it after the HTML is parsed. Most non-critical scripts should use defer.

What is critical CSS?

The small set of styles needed for above-the-fold content, inlined in the head so the page renders before the full stylesheet loads.

How do I measure a third-party script's cost?

Lighthouse lists third-party usage and blocking time. You can also block a domain in Chrome DevTools and compare results.

Can SEO plugins fix this?

Performance plugins help with minification and deferring, but page builder bloat and heavy widgets usually need template or tool changes.

Related lessons

Want someone to handle SEO for your business while you learn? The team at Remar Digital can help.