Title: preparing shortcode output before loading page
Last modified: August 15, 2020

---

# preparing shortcode output before loading page

 *  [Mostafa Shahiri](https://wordpress.org/support/users/mostafadeveloper/)
 * (@mostafadeveloper)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/preparing-shortcode-output-before-loading-page/)
 * Hi
    I am trying to create a plugin that displays a csv file as html table. It
   uses shortcode for creating html table. For small csv files it works fine, but
   for large csv files, it takes long time to read csv file. I use fgetcsv function
   for reading csv files. Is there any way to prepare shortcode output before displaying
   result? I want to read csv file before loading page. Please help me.
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [tugbucket](https://wordpress.org/support/users/tugbucket/)
 * (@tugbucket)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/preparing-shortcode-output-before-loading-page/#post-13260803)
 * Have you tried calling your functions through ajax? Like call the function, count
   the rows, when all rows are added to your variable, return.
 *  Thread Starter [Mostafa Shahiri](https://wordpress.org/support/users/mostafadeveloper/)
 * (@mostafadeveloper)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/preparing-shortcode-output-before-loading-page/#post-13261533)
 * [@tugbucket](https://wordpress.org/support/users/tugbucket/) Thanks for your 
   reply. Yes, using ajax improved loading time,but when I try to inject huge numbers
   of rows via ajax response to the table, browser is stuck and stop working for
   a few seconds.
 *  [tugbucket](https://wordpress.org/support/users/tugbucket/)
 * (@tugbucket)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/preparing-shortcode-output-before-loading-page/#post-13263934)
 * If it does load all the data even after it “hangs” put a loading animation or
   screen up and when the response comes back remove it and show your data. That
   way visually it looks fine until its finished. If its massive, like 1k rows plus,
   you might slso want to use sleep() or something similar so that you dont run 
   out of memory. If its tons of data, the browser will hang while it processes,
   not realky anything you can do but you csn make the site display that it is working.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘preparing shortcode output before loading page’ is closed to new replies.

## Tags

 * [csv](https://wordpress.org/support/topic-tag/csv/)
 * [output](https://wordpress.org/support/topic-tag/output/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [tugbucket](https://wordpress.org/support/users/tugbucket/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/preparing-shortcode-output-before-loading-page/#post-13263934)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
