Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization for google Lighthouse review #1602

Open
tbouliere-datasolution opened this issue Mar 6, 2024 · 2 comments
Open

Optimization for google Lighthouse review #1602

tbouliere-datasolution opened this issue Mar 6, 2024 · 2 comments
Assignees
Labels
enhancement Enhancement to an existing feature

Comments

@tbouliere-datasolution
Copy link
Contributor

tbouliere-datasolution commented Mar 6, 2024

Is your feature request related to a problem? If yes, please describe it.

The application currently performs very poorly in the google lighthouse test in mobile mode.
It's true that it's very difficult to optimize angular applications for this test. Even more so with a generic application.

However, there are architectural choices that prevent us from making improvements in our projects:

  • The "SharedModule" is huge, taking up 1/4 of the total size of the application.
  • Impacting dependencies such as CDK or formly are loaded by default with the ShareModule
  • Shell Module loads (even lazily) the SharedModule
  • The CMS module automatically loads all components. If an impacting component (such as a product list with slider) is declared, it will be loaded on all pages, even if it is not used.
  • Extensions for numerous dependencies. For example, order-template must be loaded on the homepage simply to present a button redirecting users to the order-template functionality.

Describe the desired solution.

  • SharedModule should be splited
  • Ideally, ShellModule should be self-sufficient.
  • CMS component should be loaded lazily
  • Extensions should export a light version of shared component for the homepage
  • Page hierarchy should be splited as chunk per page with webpack
  • Lazy load vendor dependancies should not by contains in vendors.js or common.js

Describe alternatives you've considered.

Splitting ShareModule and lazy loading CMS doesn't take so much time.
The real difficulty lies in the extensions loaded on the home page.

A first cut has been made here as a poc (~ 4/5 hour of work): https://github.com/tbouliere-datasolution/intershop-pwa/tree/refactor/split-shared-module

Provide additional context.

image

Initial webpack bundle

image

Expected splitted webpack bundle

image

AB#94658

@tbouliere-datasolution tbouliere-datasolution added the enhancement Enhancement to an existing feature label Mar 6, 2024
@andreassteinmann andreassteinmann self-assigned this Mar 14, 2024
@andreassteinmann
Copy link
Collaborator

Hi @tbouliere-datasolution, we looked at the changes and figured out several improvements in the Lighthouse test for mobile (Unused JS, FCP, TBT). Thank you for the work! We are not going to take the POC as it is but we are going to look at certain re-arrangements and improvements.

@tbouliere-datasolution
Copy link
Contributor Author

Hello Andreas.

I understand that this type of modification can be hard to integrate.
That's why we've abandoned the idea of achieving a correct ligthouse score for the time being. It would take us too far away from the initial trunk.

I can, however, add the following comments:

  • There aren't enough standalone components in the application. This tends to produce a monolytic application. Shared components and CMS components in particular should be standalone.

  • Css is only contained in scss files. There is very little component-specific css. This makes refactoring very complicated and css purging rather inefficient.
    I think this is the result of a one-for-one reworking of the work done several years ago on "inspired". It's not really state-of-the-art anymore.

  • The ui librairies, which should be in "demo" mode, are intrasectively linked to the application :

    • Bootstrap 4 is forced (NgbModal is used throughout the code). This version dates from 2018. It's over 6 years old now.
    • Font Awesome is too intrusive. Picto management via svg assets would be much more efficient.
    • Swiper is also an old version.

And once again, all these libraries are loaded into the core (some even via app.module.ts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants