My WordPress site has quite a few long posts that slow down page loading time exponentially.
This only happens when using the post_content, for example, when using the the_content()
and get_the_excerpt()
functions.
I ran some tests with the Query Monitor plugin. Load time is in addition to the page's base loading time without the_content()
.
.
Post 1 (Extremely long)
Characters: 176223
Load time: +9 seconds
.
Post 2 (Long)
Characters: 67203
Load time: +2 seconds
.
Post 3 (Average Length)
Characters: 32827
Load time: +0.25 seconds
.
It seems that the loading time dramatically increases, exponentially so, as the post_content size gets larger.
Is this normal behaviour for WordPress? Is there something I can do to make large posts load faster?
Note that this problem seems to be unrelated to any database queries. The database query time on any of these pages is between 0.03 and 0.06 seconds.
Update
I discovered that the issue originates from the wpautop
filter function. Removing this function from the the_content
filter makes my pages load fast again, but removes any and all formatting from the posts...
remove_filter('the_content', 'wpautop');