Identifying Critical Points
To identify the critical points of a module, after activating it, we need to analyze the site using Prestashop's debug tool, which allows us to see the loading times of individual resources.
Enabling the Profiler
To enable the Profiler, go to the file config/defines.inc.php
and set the constant _PS_DEBUG_PROFILING_
to true
.
define('_PS_DEBUG_PROFILING_', true);
You can also enable the Profiler from the Back Office by navigating to Advanced Parameters -> Performance
and activating the Profiler from there.
Performance Analysis
- Measuring Times:
- Analyze the loading times of the module and the hooks used.
- Static Resources:
- Examine the static CSS and JS resources loaded by the module: evaluate where they are positioned and why they are loaded.
Optimization Scenarios
Let's look at some typical optimization scenarios:
Excessive Static Resources:
- Reduce the number of CSS and JS files loaded to improve loading times.
Conditional Loading:
- Load resources only when necessary, for example, only on specific pages where the module is actually used.
Minification and Combination:
- Minify and combine CSS and JS files to reduce the number of HTTP requests.
Module Override
To override the behaviors of a module, you can create an override of the module itself. This operation will be detailed in the following section.