Import Data slow (API)
-
Hi,
I have an issue with slow loading times of the table because:
I get the values via shortcode from a google spreadsheet API and the more shortcodes I use, the slower the table load time. The page loads like >5 seconds longer compared to pages with no table.
This is my plugin, where I get the data:
`<?php
/* Plugin Name: Custom Plugin for Code
Description: Plugin for extra theme independent code
*/function sheet_value_shortcode($atts) {
$API = ‘mykey’;
$google_spreadsheet_ID = ‘sheetID’;
$api_key = esc_attr( $API);$location = $atts[‘location’];
$get_cell = new WP_Http();
$cell_url = “https://sheets.googleapis.com/v4/spreadsheets/$google_spreadsheet_ID/values/$location?&key=$api_key”;
$cell_response = $get_cell -> get( $cell_url);
$json_body = json_decode($cell_response[‘body’],true);
$cell_value = $json_body[‘values’][0][0];
return $cell_value;
}
add_shortcode(‘get_sheet_value’, ‘sheet_value_shortcode’);Is there any way how to improve this? for example just make 1 API call to get a range and then pull the data from there (via shortcode)?
Thanks for any hint ??regards,
lukasThe page I need help with: [log in to see the link]
- The topic ‘Import Data slow (API)’ is closed to new replies.