Performance: Why content types matter
MEDIUM IMPACT
Content types affect how quickly the main content loads and how stable the page layout remains during loading.
<?php // Using custom post types for different content $args = array('post_type' => 'product'); $query = new WP_Query($args); while ($query->have_posts()) { $query->the_post(); the_title(); the_content(); } wp_reset_postdata(); ?>
<?php // Using only posts for all content types $args = array('post_type' => 'post'); $query = new WP_Query($args); while ($query->have_posts()) { $query->the_post(); the_title(); the_content(); } wp_reset_postdata(); ?>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Single post type for all content | High - many nodes | Multiple reflows due to mixed content sizes | High paint cost from varied layouts | [X] Bad |
| Custom content types with targeted queries | Lower DOM nodes per type | Single or minimal reflows with stable layout | Lower paint cost with consistent design | [OK] Good |