Skip to content

Conversation

@cconard96
Copy link
Contributor

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.

Description

One of a few possible optimizations to improve GLPI performance. I only consider this a short-term optimization when there are better ways to handle this and it is not a substantial optimization on its own.

Dumping the entire safe CFG_GLPI array in a JS script on the page is excessive.
We only really use the "root_doc" config in most places.
Even in plugins as far as I can see, there are very few non-"root_doc" uses of this variable.
Instead of dumping the entire config, I replaced it with a proxy to transparently lazy-load missing values.
This would be a synchronous call but it was necessary to not break existing code and the need to fetch additional configs should only rarely come up.
I believe the faster initial page loads would be worth it.

Tested in production env.
Seeing approximately 8kb (compressed size) less transferred per page and approximately 30ms less page download times.
Seeing "Time to DOM interactive" and "Time to DOM complete" metrics a 100-200ms lower on average but this can vary a lot.
Minor performance improvements and data usage reductions should be seen across the entire app for initial page loads.

@trasher
Copy link
Contributor

trasher commented Oct 17, 2025

Please fix lint

@cedric-anne cedric-anne added this to the 11.0.2 milestone Oct 30, 2025
$.ajax({
type: 'GET',
url: CFG_GLPI.root_doc + '/Session/Config/' + prop,
async: false,
Copy link
Contributor

@AdrienClairembault AdrienClairembault Oct 30, 2025

Choose a reason for hiding this comment

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

As discussed on similar changes, we might disagree on this but I am against adding synchronous calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't disagree on this point. If it is async though, something will try using a config value that isn't loaded, trigger it to be loaded, and immediately get no value since it didn't wait for the response. I don't want it to be synchronous but it needs to be to make this work with existing code.

We could close the PR and leave the entire dump available, but I'm just trying to improve performance as best I can with what we have for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants