I am currently trying to speed optimise the fetching of the data via the remote API.
I am using it in this way:
$response = wp_remote_get('https://some-api.com/endpoint'); $response_body = wp_remote_retrieve_body($response); $data = json_decode($response_body, true);
It returns an array of data, that I am traversing and saving to appropriate variables with which I later insert the data where I want it to be inserted.
All of this is done via AJAX, so that the data is being inserted dynamically.
The whole thing takes around 400-600ms. But if I try to access the api endpoint directly with pasting the API URL in the URL bar in my browser it just takes around 50ms. Does the
json_decode & saving and outputting from variables account to the other 400-500ms? Is there any other way that I could minimase the impact of loading time?