How to capture document.ready or window.load events in Gatsby

I think you should add these event listeners in the gatsby-browser.js:

// gatsby-browser.js
// ES6
export const onClientEntry = () => {
  window.onload = () => { /* do stuff */ }
}

// or commonjs
exports.onClientEntry = () => {
  window.onload = () => { /* do stuff */ }
}

You don't have to check for window there because this file is only run on the client side. Here's the full list of available hooks.

also AFAIK document doesn't have a ready event, it's a jQuery thing. You might be interested in DOMContentLoaded event, though there's some small different between that and jQuery's ready IIRC.