DEV Community

Discussion on: What was your win this week?

 
ben profile image
Ben Halpern

Yeah, we store HTML in the DB, so only ever re-compute on changes. (This approach could change slightly over time to give us more flexibility, but it works well for efficiency).

And yeah — FastImage seems to allow you to look up either size, type, or animated, but doesn't let you open up the image to look for everything at once. 🤷‍♂️

Thread Thread
 
grahamthedev profile image
GrahamTheDev

Thought I had replied, must have closed browser by mistake 🙄

Looks like you are right, Line 223 in fastimages

 @property = if @options[:animated_only]
      :animated
    elsif @options[:type_only]
      :type
    else
      :size
    end
Enter fullscreen mode Exit fullscreen mode

So it looks to be animated, type or size as you thought.

Pretty sure you could extend it and just call them both together but that is probably an over optimisation!

Great solution for CLS either way ! ❤

Thread Thread
 
ben profile image
Ben Halpern

I’d consider this an over optimization for the matter of this first PR, but once it’s merged, a dedicated task to optimize this makes sense.