title: Gatsby image onLoad fires in develop mode but not in build
body: <p>I recently tried out developing a site in Gatsby, and I have an animation that triggers when an image fires its onLoad event. This works fine in <code>gatsby develop</code>, but when I do <code>gatsby build</code> onLoad never fires.</p>
  <p>If I manually change the image src in inspect element to make it load a new image, the event fires. I'm guessing that it has to do with server-side rendering, but I don't know how to fix this without forcing everything to render client-side. The image still takes time to load up after all, so why won't onLoad fire in the build? How can I make it fire?</p>
  <p>Here's the code with some irrelevant parts cut out.</p>
  <pre><code>import React from 'react';
  import  * as bannerStyles from './banner.module.css';
  import negative_forest from '../images/negative_forest.png';
  
  export default class Banner extends React.Component {
      constructor(props) {
          super(props);
          this.wrapper = React.createRef();
          this.img = React.createRef();
          this.textContainer = React.createRef();
          this.onImgLoad = this.onImgLoad.bind(this);
      }
  
      render() {
          return &lt;div className={bannerStyles.wrapper} ref={this.wrapper}&gt;
              &lt;img onLoad={this.onImgLoad} src={negative_forest} alt=&quot;Negative Forest&quot; className={bannerStyles.img} ref={this.img} /&gt;
              &lt;div className={bannerStyles.textContainer} ref={this.textContainer}&gt;
                  &lt;h1 className={bannerStyles.text}&gt;Title&lt;/h1&gt;
                  &lt;h2 className={bannerStyles.text}&gt;Subtitle&lt;/h2&gt;
              &lt;/div&gt;
          &lt;/div&gt;;
      }
  
      onImgLoad() {
          alert('loaded image');
          this.img.current.style.animation = `${bannerStyles.imgfade} 3s linear 0s 1 normal forwards`;
          this.textContainer.current.style.animation = `${bannerStyles.textfade} 3s linear 0s 1 normal forwards`;
      }
  }
  </code></pre>
  <p>edit: I tried loading the site in a different browser, and it fired the event the first time but not subsequent times, so I think it has to do with caching instead. My bad.</p>