Actions
Feature #44415
openReduce icon rendering time by caching sprite paths
Status:
New
Priority:
Normal
Assignee:
-
Category:
Performance
Target version:
-
Resolution:
Description
IconsHelper#svg_sprite_icon calls asset_path to resolve the sprite path for every icon rendered on a page. However, a page typically uses only a few sprites: Redmine's bundled icons.svg, plus icons.svg plus any icons.svg provided by the theme or plugins. The same paths are therefore resolved many times.
The attached patch memoizes the resolved path for each sprite in the view instance, so each path is resolved only once per request.
On my development machine, the total time for 370 calls to sprite_icon, which calls svg_sprite_icon internally, on an issue page with 30 journals and 30 attachments decreased from 3.9 ms to 2.2 ms, a reduction of about 40%.
Files
Actions