Tips & Tricks to increase your score.

This is part 2 of some useful tips and tricks to increase Lighthouse score and thereby reduce first page load time. You can find Part 1 here.

To achieve a good score we have to reduce as much as possible the code elaboration like heavy task or heavy DOM manipulation.

For example: if we have a list where there is a price with a currency symbol we easily write the following code:

app.component.ts
...
list = [{name: 'item 1', price: '50 €'}, {name: 'item 2', price: '70 €'}];app.component.html
...
<div *ngFor="let item of list">
<div>Price <span [innerHTML]="item.price"></span></div>
</div>

If…


Tips & Tricks to increase your score.

This article requires a good knowledge of Angular.

If your score is low despite having applied common optimization techniques such as well described here or here then read the techniques and tricks described in this series of articles.

In mobile (the most important test device) a my optimized page increased from 68 points to 96 points, and in desktop from 96 to 100 points.
This using Chrome 90 that fixes the LCP (Larget Contentful Paint) issue.
Another optimized page, and having used the Chrome 87, increased from 34 to 83 points in mobile test.


Often is useful to load environment variables without rebuilding the project, like when deploying the same project to different servers (or docker instances) with a different configuration.

The target is to load the config WITHOUT wait and perform an HTTP request.
This technique avoid a negative impact on the first load page (did someone say Lighthouse?).

So the best strategy is to load the environment variables when run the server-side rendering (SSR) node process and store they into the index.html file.
See how to do it:

  1. Put the environment variables into a json file, and save as env.json …

Francesco Cantarella

15 years full stack developer...

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store