Performance: Enclosing shortcodes
This affects page load speed and rendering because enclosing shortcodes can add extra processing time during content parsing and increase DOM complexity.
[box content="content" /][box][content][/box]
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Enclosing shortcode | Adds nested DOM nodes | Triggers 1 reflow per shortcode | Higher paint cost due to complexity | [X] Bad |
| Self-closing shortcode | Minimal DOM nodes | Single reflow | Lower paint cost | [OK] Good |
box with content inside?[box]Content here[/box] correctly shows [box]Content here[/box]. Other options are either self-closing or invalid.[highlight color="yellow"]Important text[/highlight], what will be the expected behavior?[frame]Content here[frame][alert type="error"] that wraps content and shows it with a red background. Which is the best way to write the enclosing shortcode usage?[alert type="error"]Warning![/alert] correctly uses [alert type="error"]Warning![/alert]. [alert type="error" /]Warning! is self-closing and incorrect for enclosing content. [alert]Warning![/alert type="error"] misplaces attribute in closing tag. [alert type="error"]Warning! has incorrect closing tag syntax.Pass the test and this pattern moves unknown