Skip to main content
2 of 8
added 10 characters in body
Niall Murphy
  • 2.8k
  • 12
  • 15

How to replace a "use-ajax" link that's auto-clicked on page load? It locks up other JS on the page until done

I have a large form that is often used but takes 2-3 seconds to load. To get around this, I have it loaded by clicking the <a id="doc_ready_link" class="use-ajax" link with JS on page load.

document.querySelector('#doc_ready_link').click(); 

On faster machines like my laptop or phone, this is fine and I have a fast page load and a spinner on the form link.
But on slower laptops and phones, other JS stuff like the menu doesn't work until it's loaded giving a bad UX.

How do I get that form loaded with ajax after page load without locking up the browser?

Thanks.

Niall Murphy
  • 2.8k
  • 12
  • 15