I’m looking to find the best way to go about building a frontend dashboard page with multiple components/widgets. Each widget would be looking to make a GET request from an internal API on page load, and then populate the content of that widget with the data from the response.
The page is likely to have dozens of different widgets with various metrics and some API requests will likely take a considerable amount of time more to process than others. So ideally, the solution needs to be asynchronous and not block the page rendering. Ideally, the widgets would have a placeholder/spinner until the data returns and the placeholder is replaced.
I believe I could accomplish this via Javascript. Where each widget would have some placeholder markup and an accompanying script. The script makes the request, and processes the results, then injects the markup into the placeholder div.
However, I’m wondering if there is another possible & preferable way to accomplish this.
I was able to install php’s guzzle in my custom theme, and set up a way of making asynchronous requsts, however this approach (at least so far) is render blocking, and the longest request determines when everything gets populated.
So, yeah, is there another approach? Can something like this be done in PHP, or is it necessary to use Javascript here? Any advice on the best way to approach this would be appreciated.
[ad_2]