tags:

views:

31

answers:

3

I have one script that loads very quickly, but I have another script that I want to run with that script, but that scripts processes a LOT slower. The second script doesn't need to output anything to the user, it only needs to run. Is there a way I can include it locally, without making the user have to wait for it to load?

EDIT: I'd really like to keep this part pure PHP if possible.

+2  A: 

make a call to it through ajax. that way everything can load on the page, and that can run in the background.

you'll have to be careful though that the user refreshing the page won't run the script again and overload your server.

contagious
I don't know any ajax. I'd really like to keep this part pure php. If there are no other options, I'll go learn Ajax. Thanks
Rob
A: 

You can also have the second script output a 1x1 pixel image, and include the script using img tags at the bottom of the page.

john010117
That's very interesting, but it would still wait for that image to load.
Rob
+1  A: 

Due to my lack of reputation I cannot yet leave a comment. "learning Ajax" really isn't difficult, and I think it would be your best solution (as contagious said). If you simply load the jQuery library it can be something as simple as:

jQuery(function($) {
    $.post( 'http://url.com/' );
});
Kerry
+1, its pretty lame not being able to leave helpful comments.
Rob
Thank you -- my reputation jumped a bit, so next time it will be a comment :)
Kerry