Support » Fixing WordPress » Speed-up wp-syntax?

  • Hi,
    I have tried running the wp-syntax plugin for syntax highlighting. Problem is, it is painfully slow for me, especially on the index page with a bunch of posts at once. I am looking for some advice on possibly speeding it up. I don’t want to abandon it since it has the prettiest output by far.

    I am sure it is wp-syntax after a process of elimination. I even know which bit of wp-syntax is the “problem”.

    wp-syntax registers 6 filters. “Before” and “After” filters for the_content, the_excerpt and comment_text. The problem is that with my pretty large chunks of code the before filter for the content provide results that take up a lot of time for the corresponding after filter. The problem is compounded on index pages where the total number of lines of code might easily be 10-fold.

    I would like to avoid trying to replace the regexp used in those filters. Instead I was wondering if there is a way to make sure that the plugin only parses visible content. I have my index showing the excerpts only and thought that would make a difference but it appears that the whole post gets parsed anyway. Is this standard WP behavior?

    If so, is there a variable to check or function to call to find out if the_content will be displayed and should be parsed?

Viewing 1 replies (of 1 total)
  • I found two ways of dealing with this…

    As a WP-noob I did not expect WP to apply all filters to the whole content just for the purpose of generating an excerpt. But this is exactly what WP does. For some filters this is probably a good thing but it does waste a lot of processing for large posts.

    The simply fix is to put some test into the excerpt field of the post. Adding a manual excerpt avoids this extra filter parsing processing. Simple enough once I realised it would make a difference.

    So, all is well again and request times are down by 90%. 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Speed-up wp-syntax?’ is closed to new replies.