IMG Dom elements gets error even before connect()

My Rails app uses Twitter avatars. I’m using stimulusjs to refresh a twitter image avatar whenever the previous avatar url fails. However, it looks like the image onerror() event is happening even before connect() is called on the StimulusJs controller.

I am including the stimulusjs controllers in the page and prepackaged via rails webpack. Any idea, how to get stimulusjs to be called earlier? or Stimulus unable to cater for this use case?


maybe this thread and this particula comment can help

1 Like