From 2b46f8f8541c655ea47020abab8a00e395087df8 Mon Sep 17 00:00:00 2001 From: Adrian Marin Date: Fri, 29 Nov 2024 00:48:47 +0200 Subject: [PATCH] perf: svg loading improvements (#3470) --- app/helpers/avo/application_helper.rb | 2 +- lib/avo.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/helpers/avo/application_helper.rb b/app/helpers/avo/application_helper.rb index d3bc0f216..af231f14b 100644 --- a/app/helpers/avo/application_helper.rb +++ b/app/helpers/avo/application_helper.rb @@ -65,7 +65,7 @@ def svg(file_name, **args) file_name = "#{file_name}.svg" unless file_name.end_with? ".svg" - with_asset_finder(::Avo::SvgFinder) do + Avo::CACHED_SVGS[file_name] ||= with_asset_finder(::Avo::SvgFinder) do inline_svg file_name, **args end end diff --git a/lib/avo.rb b/lib/avo.rb index d2bb5de06..58aa29743 100644 --- a/lib/avo.rb +++ b/lib/avo.rb @@ -19,6 +19,7 @@ module Avo COOKIES_KEY = "avo" MODAL_FRAME_ID = :modal_frame ACTIONS_BACKGROUND_FRAME = :actions_background + CACHED_SVGS = {} class LicenseVerificationTemperedError < StandardError; end