I’m looking to optimize my application. It uses the Twitter and the Facebook API and loads large files to be displayed on the users screen. Right now, I am running the script linearly, calling one file that includes both API calls using AJAX and loading all of the information onto the screen. Would it be faster for me to separate the two API calls into two different files and then load each one separately with AJAX? This way, if one response was taking longer then the other, the faster one would still be displayed.
If it matters, I’m using PHP and CURL for API calls.
Certainly it would be better if the AJAX calls don’t depend each other. You can also do this at the PHP side using
curl_multi_initthat executes HTTP calls in paralell.Sample from the PHP manual: