Load shortcode only when visible

I’m using a plugin called WPDataTables to display small tables of data; typically fewer than 10 rows with only 3-4 columns each.

The tables are displayed using shortcodes.

I’m running into severe lag, as the plugin uses cURL to fetch the data from Google Sheets hosted on the web, and each fetch seems to take about 1 second. This would be fine if there were only 1 table on each page. For my purposes, I typically have to load up to 10 tables on a single page, which means the load time is typically closer to 10 seconds. Essentially unusable.

Is there a way to load the shortcodes only when they’re visible and hide them in something like an accordion container until needed?

Effectively, opening the accordion would load the shortcode, which would take about a second, but eliminate the egregious cumulative 10-second wait.

Thanks

Hi Omar,

Thanks for reaching out. Unfortunately, we’re not familiar with other 3rd party plugin or libraries, but as long as the codes are properly enqueue based on Wordpress standard then it should work. You might need to consult the plugin developer instead of how to improve the fetching of the said data.

Thank you for understanding,

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.