Javascript tracker: snowplowOutQueue flush when snowplow is loaded

I use javascript tracker for triggering events from my web application.

There’s an issue I’m facing when working with windows that reload.

I need to send a set of events when a form is submitted. The problem is after submission, page refreshes and my snowplow object is not available anymore.

The library adds these failed events to a local storage variable with key snowplowOutQueue_snowplow_cf_get , but are only triggered when that page is visited again & an event trigger happens.

Is there a solution/configuration through which all the events in localStorage can be triggered at library load/ explicitly through code on a timely basis.