Performance: Creating shortcodes
MEDIUM IMPACT
This affects page load speed and rendering because shortcodes add dynamic content processing during page generation.
<?php function cached_shortcode() { $data = get_transient('cached_data'); if (!$data) { $data = file_get_contents('https://api.example.com/data'); set_transient('cached_data', $data, HOUR_IN_SECONDS); } return $data; } add_shortcode('cached', 'cached_shortcode'); ?><?php function slow_shortcode() { $data = file_get_contents('https://api.example.com/data'); return $data; } add_shortcode('slow', 'slow_shortcode'); ?>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Slow shortcode with external API call | Minimal DOM nodes | 0 reflows (server-side delay) | Blocks initial paint | [X] Bad |
| Cached shortcode output | Minimal DOM nodes | 0 reflows | Non-blocking paint | [OK] Good |