Brighton SEO July 2021 How JavaScript is preventing you from passing Core Web Vitals ?
1.
2. Agenda
1. Why should we bother with JS?
2. Indexing JS content
3. What are Core Web Vitals?
4.How to pass Core Web Vitals?
5.Most common JS issues and solutions
6.Example of fixing JS issues and influence on
CWV
7. How to audit Core Web Vitals?
8.How to avoid JS mistakes
15. Analysis of pages across various
industries not passing CWV
No of
pages
Failing
CWV
Failing
LCP
Failing FID Failing
CLS
JavaScript
Issues
22 19 17 2 12 22
16. The problem is not JS itself, but the
way it is implemented.
22. By default, JavaScript files are
render-blocking because they
block the browser from dealing
with other page load tasks, thus
delaying your page's First Paint.
26. Code splitting
Separate JS into critical and non-
critical. This will lead to reducing
render blocking behaviour as only
critical JS is loaded first.
27. This is the process of removing all JS
that your page isn't currently using.
For example pieces of code from
previous site versions, or code used
during tests.
Dead code elimination
33. ● Implement code splitting
● Removing unused code
● Caching your code with the PRPL
pattern
● Minifying and compressing JS files
34. ● Push (or preload) the most important
resources.
● Render the initial route as soon as possible.
● Pre-cache remaining assets.
● Lazy load other routes and non-critical assets.
PRPL pattern
35. Minification - removing whitespace
and anything else that is not
necessary to create smaller but valid
code.
Minifying JS files
36. Compression - modifying data with
compression algorithm.
● Dynamic - compressing assets on the go
as they get requested by the browser.
● Static- compressing and saving assets.
Compressing JS files
42. ● JS at the bottom of HTML
● Async or defer attribute
● Custom solutions
● Plugins
43. JS at the bottom of HTML document,
it's considered best practice as the
higher the code is the sooner it will be
downloaded and executed.
JS at the bottom of the HTML
44. ● Async - load JS asynchronously AND fetch
script when resources become available, once
downloaded HTML is paused to execute JS
● Defer - load JS asynchronously AND wait to
execute JS until the HTML parsing is
complete
Async or defer attribute
46. Unnecessary legacy code is often being
shipped to modern browsers even
though they have native support for
modern JavaScript features
47. ….this increases
the size of the
JavaScript files
being downloaded,
parsed, and
executed by the
browser.
48. Adopting a modern script
deployment strategy can reduce
the amount of code shipped to the
majority of your visitors,
improving their page experience.
69. Thank you !
Thanks for listening to my talk!
If you have any questions or comments or just want to have a chat,
please contact me !
Email: izabela@creatosmedia.co.uk
Twitter @izzy_cm