Performance: WP_Query class
HIGH IMPACT
This affects page load speed by controlling how many and which posts are fetched and rendered on a page.
$query = new WP_Query(array('posts_per_page' => 10, 'paged' => get_query_var('paged', 1)));
$query = new WP_Query(array('posts_per_page' => -1));
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fetching all posts (-1 posts_per_page) | High (many nodes) | Multiple reflows | High paint cost | [X] Bad |
| Fetching limited posts with pagination | Low (few nodes) | Single reflow | Low paint cost | [OK] Good |
| Meta query without meta_query array | Medium | Single reflow | Medium paint cost | [!] OK |
| Meta query with meta_query array | Low | Single reflow | Low paint cost | [OK] Good |