Old habits and variables

I’m struggling to break old coding habits and I have a question about one in particular. My app uses a lot of specialised icons each of which is SVG and is displayed using an HTML element.

My old habit has me reading them all into variables when the app loads. Then when they are used, the HTML points to the variable that holds the SVG code as text. In the dark ages of computing, this was faster than doing a DB search every time you wanted to display one.

However, I’m wondering if using Do a Search for Icons every time I use one is just as fast if bubble is remembering that it already searched for that icon so does not do it again.

Thoughts?

Use an empty group that’s almost invisible and load the thing onto it. Then refer to the groups value in all the places.

That way you won’t have to change things at 100 places :slight_smile:

I’m doing exactly that already @gaurav - I have a Group called Variables and inside it, I have Text elements that Do a Search for Icon at page load so I have every icon I could need stored in those Texts then I call them from there. However, my question was if that was even necessary. Should I just Do a search for Icon every time I need it? Is bubble smart enough to know it already loaded it (SPA) and so it would skip the search. I have circa 100 SVG icons and I won’t need all of them all of the time so should I load them all initially so they are there? Or, if I used Do a search for Icon every time I need one would bubble recognise that it already has that one loaded and avoid the search?

Yes bubble is smart enough to not do a search everytime. I think this was mentioned in one of the performance threads on forum by Josh

1 Like

Here’s the thread:

Perfect. Thank you @gaurav that’s just what I needed to know.