Jump to content

make onload function load faster


phpchick

Recommended Posts

Hi, I have a website that autoloads a modal window. The behavior currently is that it waits until the entire page is loaded before the modal pops up. Sometimes this can take a long time to load. I was wondering if there was a way to make the modal pop up immediately, regardless of whether the page is done loading. The page can finish loading while the modal is up obviously.

 

This is what I am currently using to call the modal.

 

<body  <?php  echo  "onload='$(\"a#various3\").trigger(\"click\");'  "; ?> >

Link to comment
https://forums.phpfreaks.com/topic/238566-make-onload-function-load-faster/
Share on other sites

Since this a modal pop-up you shouldn't place the code within the head of your document, as the body's HTML hasn't been constructed yet. Instead you should place it just before the closing body tag. This means you escape waiting for the onload to complete, but the DOM structure exists for you to make adjustments.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.