wallyfoo

wallyfoo

Fontawesome, LiveView, and agonizingly slow load times (fixed with Tailwind’s hero icons)

I was working on a LiveView page that loaded hundreds of points of data. I probably should have paginated the data load, but this is an internal tool, so that sort of thing isn’t particularly important to me for this project.

On first load, boom. 368 records from the database, filtered to exclude a number by default, mounts in under a second. I add a checkbox to reload the data, adding in all the records, phx-update=“replace”, and I get a stopwatch out. 12 seconds to reload the list, now with 435 records. That’s weird. The database returns the data in microseconds, but the update on the page prompted Firefox to advise me to stop loading scripts.

I fire up the profiler, but don’t get very far with that – the data is inconclusive. So I decide to start reducing the test case. A straight inspect of the individual maps with no markup at all update instantaneously. Ok. I start adding back plain divs. Lightning. I start thinking that it may be related to javascript mounting phx-hooks on each of the component divs. I conservatively add a hook back to the component expecting it to break. Nope. Blink and you miss it.

I add my fontawesome icons back to the buttons on the div. Bingo. Very slow. I add all three icons to the component. Very very very slow. I remove them again, and I can say I solved where the problem was. My guess is that the way fontawesome loads in from the hosted kit apparently doesn’t have a “complete” signal until every single icon is loaded, and I imagine that morphdom is simply doing as it’s told, waiting to present the data until it knows it’s loaded.

Easy fix. I’ll use text instead of icons. No biggie. Though, I notice the core components shipping with the latest Phoenix supplies us with tailwind’s hero icons. Why not give those a shot? They’re included in Phoenix, so it’s likely there’s not this bonkers slow loading behavior.

And there’s not. The hero icons load near instantly.

I’m just leaving this short adventure in troubleshooting LiveView load times here in case any other hapless developers trip on their own shoelaces like I have.

Most Liked

mayel

mayel

I had a similar experience in the past, quite shocking! Anyway, quick plug for iconify_ex | Hex which uses a similar approach as Phoenix’s heroicons (among other methods available) but provides many more icon sets.

LostKobrakai

LostKobrakai

How did you include the icons? Icon font, raw svg, svg loading external asset, image, …?

Phoenix currently uses a data url as a mask, which is deduplicated and put on the css by tailwind. Tailwinds prunning also makes sure only icons used are added.

Where Next?

Popular in Discussions Top

matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New
jswny
I would like to better understand what the advantages/disadvantages of umbrella applications are compared to structuring your app as as s...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39523 209
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
ejpcmac
I have discovered Nix last month and I am currently on my way to migrating to it—both on macOS at home and the full NixOS distrubution at...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New
und0ck3d
Hello everyone! A few days ago I’ve created a topic here about how people were creating CMSs with Elixir and Phoenix. I’ve been studying...
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New
kostonstyle
Hi all How can I compare haskell with elixir, included tools, webservices, ect. Thanks
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

We're in Beta

About us Mission Statement