2

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');

5
  • Are you running ads or complex javascript or anything like that?
    – Welcher
    Commented Apr 25, 2017 at 3:07
  • Not really. Problem still exists when I turn off JavaScript in my browser. It seems to be a PHP problem.
    – Swen
    Commented Apr 25, 2017 at 11:27
  • 2
    1. local machines are very bad place to measure performance. 2. from looking at the autop code it might consume memory in linear relation with the length of the content and the number of line breaks seems to play an important role, as also some other types of entities, which leads back to point 1 if you machine is memory starved you might run into many page swaps. Commented Apr 25, 2017 at 12:38
  • @MarkKaplun Strangely enough, you were right. I tested this same thing on my VPS and there is no performance issue there. Still, I'm left wondering how that will be when there's more than one person visiting these pages.
    – Swen
    Commented Apr 25, 2017 at 22:16
  • 1
    that is not strange at all, for example when you test on the VPS you do not run a very heavy application called "browser" on it. All browsers are very memory hungry, and then you probably have other apps running as well. Commented Apr 26, 2017 at 2:57

1 Answer 1

1

This is not the normal behaviour of Wordpress.

As others have mentioned it could be JS render blocking as the Database has already finished grabbing the data and displaying.

I would first investigate your browser console and see what its returning on the network tab and if the console has any 404s as a broken font or a broken image can cause delays.

Also if you have any images on the posts, check their size, if they are over 1MB in file size and above 1920 x 1200 in resolution then you are causing slow downs as the files are big. (Videos too, always, always use YT or Vimeo, anything that is not stored on your local server, it will slow it down unless you are on a high end server)

Finally, if possible run the site through https://gtmetrix.com/ as it can help identify where things are falling down and slowing the site down.

PS,

You mentioned you edited the_content function, if you edit the Wordpress Core, this will be overridden when Wordpress upgrades. Never ever edit the core of wordpress or a plugin.

I hope this helps in some way! If you have any queries just fire away.

Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.