Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a site that is performance critical. Doing shortcodes I thought about the time the server needs to parse and return the content, instead to allow some HTML (<div class="redletter">) to go through the TinyMCE editor. In the meantime, my code for that is:

// [redletter]Content[/redletter]
add_shortcode('redletter', 'redletter_do');
function redletter_do($atts, $content = null)  {
    return '<div class="redletter"' . do_shortcode($content) . '</div>';
}

Performance critical or not, I think that nothing could beat a button to allow a <div> pass through directly in the visual editor and show - like it does when you press the [B] button to make <strong>.

So, i'm between keeping the shortcode, or making a TinyMCE button for <div class="redletter"> and showing the result in the visual editor.

share|improve this question
add comment

2 Answers

I'd say make the button--but not for performance reasons.

I think if you benchmark it, you'll find that any performance overhead added by running a simple function like this (one that does some simple string concat) is quite minimal. Or, at least, down to fractions of fractions of a second on a decent server.

If you're under very high load, and are worried about performance at this level, you should probably focus on a good caching layer and a fast server. We (and by we I mean our awesome sysadmin guy) have recently been playing with an nginx / varnish setup, and it's boosted performance to an unbelievable degree. (See this guy, who got it to work very well)

Of course, it's not a silver bullet, and you should always have an eye toward reducing the number of queries run, requests made, etc. So I get your intent. The kind of functionality you're attempting with this question is admirable (a TinyMCE button is a MUCH better user experience than a shortcode), but I don't think it'll help much when it comes to performance.

share|improve this answer
    
+1 Having APC serving precompiled scripts makes a huge difference. Nice article you linked there btw! I'm going to test that out –  onetrickpony May 18 '12 at 0:44
    
Thanks! I try to make code the best way from the bottom, so that way, if something goes wrong (like always), I can shrink the checklist. Nice article too. Faved instantly. –  DarkGhostHunter May 20 '12 at 1:11
add comment

Well, in terms of performance, I think is always better to avoid any "postmanipulation" to the post_content column in your database.

THe problem here as only one solution: making a TinyMCE plugin, a total pain in the ass but affordable. That way you can edit directly your HTML and avoid that manipulation done by shorttags. It's like the hard but correct way to speed up performance.

And well, I made a tiny TinyMCE plugin.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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