Performance: CMS architecture overview
HIGH IMPACT
This affects how quickly the CMS delivers content to users and how efficiently it handles page rendering and database queries.
<?php // Use WP_Query with prefetching comments or caching $posts = new WP_Query(array('posts_per_page' => 10)); $comments_cache = get_comments(array('post__in' => wp_list_pluck($posts->posts, 'ID'))); // Render posts and comments from cached data foreach ($posts->posts as $post) { setup_postdata($post); echo get_the_title($post); foreach ($comments_cache as $comment) { if ($comment->comment_post_ID === $post->ID) { echo $comment->comment_content; } } } wp_reset_postdata(); ?>
<?php // WordPress template with multiple heavy queries inside the loop while (have_posts()) : the_post(); $comments = get_comments(array('post_id' => get_the_ID())); foreach ($comments as $comment) { echo $comment->comment_content; } endwhile; ?>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple queries per post | High (many DB calls) | High (delayed content) | High (slow paint) | [X] Bad |
| Batch queries with caching | Low (few DB calls) | Low (fast content) | Low (quick paint) | [OK] Good |