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

Speedup Lizmap Html page loading by adding preload link #5532

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rldhont
Copy link
Collaborator

@rldhont rldhont commented Mar 7, 2025

Documentation about preload link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload

  • Add preload for CSS and JS files added to the HTML pages
  • Add preload for fetch request in Map pages

@rldhont rldhont added user interface run end2end If the PR must run end2end tests or not php Pull requests that update Php code backport release_3_9 labels Mar 7, 2025
@github-actions github-actions bot added this to the 3.10.0 milestone Mar 7, 2025
@rldhont rldhont force-pushed the speedup-lizmap-preload-link branch from 2265b8c to 38e13ec Compare March 7, 2025 09:48
@rldhont rldhont marked this pull request as ready for review March 7, 2025 09:49
@nboisteault
Copy link
Member

I'm not sure but it might block the HTML rendering.
It would be interesting to test against lighthouse to see if it improves its score.

@josemvm
Copy link
Collaborator

josemvm commented Mar 7, 2025

hi @rldhont
sorry, i don't know if the problem is related to this issue, but in lwc 3.8 there is a strong and visible delay in loading project images after cleanning the lizmap cache

@rldhont rldhont force-pushed the speedup-lizmap-preload-link branch from 38e13ec to a198ef7 Compare March 7, 2025 10:38
@rldhont
Copy link
Collaborator Author

rldhont commented Mar 7, 2025

I'm not sure but it might block the HTML rendering. It would be interesting to test against lighthouse to see if it improves its score.

From https://stackoverflow.com/questions/36641137/how-exactly-does-link-rel-preload-work

For example, the application can use the preload keyword to initiate early, high-priority, and non-render-blocking fetch of a CSS resource that can then be applied by the application at appropriate time:

@rldhont
Copy link
Collaborator Author

rldhont commented Mar 7, 2025

@nboisteault according to mdn, preload should not blocked the page

The preload value of the element's rel attribute lets you declare fetch requests in the HTML's , specifying resources that your page will need very soon, which you want to start loading early in the page lifecycle, before browsers' main rendering machinery kicks in. This ensures they are available earlier and are less likely to block the page's render, improving performance. Even though the name contains the term load, it doesn't load and execute the script but only schedules it to be downloaded and cached with a higher priority.

@rldhont rldhont force-pushed the speedup-lizmap-preload-link branch from a198ef7 to 0d91bf9 Compare March 7, 2025 11:25
@@ -16,6 +16,24 @@ class AbstractLizmapHtmlResponse extends jResponseHtml
{
protected $CSPPropName = 'mapCSPHeader';

protected function outputJsScriptTag($fileUrl, $scriptParams)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions will implicitly add a preload tag for each resource loaded with addJSLink/addCssLink, no ?

@rldhont rldhont force-pushed the speedup-lizmap-preload-link branch from 722ef2c to 23750aa Compare March 7, 2025 14:33
@rldhont rldhont force-pushed the speedup-lizmap-preload-link branch from 23750aa to b24ccb5 Compare March 7, 2025 14:56
@rldhont rldhont marked this pull request as draft March 7, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3_9 php Pull requests that update Php code run end2end If the PR must run end2end tests or not user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants