'Load part of the post content asynchronously WordPress

In each post, I load an audio file by making an http request to a third party service. I use the filter below and I make this request inside the add_before_content function.

add_filter('the_content', 'add_before_content');

This is causing a performance issue for us. Is there a way I can do that asynchronously so that the post content loads without the audio (and returned from the json-api without it) then the audio request/load later after the text content?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source