Performance: Site identity and branding
This affects the initial page load speed and visual stability by controlling how site logos, titles, and icons load and render.
Jump into concepts and practice - no test required
<?php if (has_custom_logo()) { the_custom_logo(); } ?><h1><?php bloginfo('name'); ?></h1><!-- Use optimized logo with width and height attributes -->
<?php if (has_custom_logo()) { the_custom_logo(); } ?><h1><?php bloginfo('name'); ?></h1>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unoptimized logo without size attributes | Minimal | Multiple reflows on image load | High paint cost due to resizing | [X] Bad |
| Optimized logo with width/height and lazy loading | Minimal | Single reflow | Low paint cost | [OK] Good |
Site Identity section in WordPress Customizer?add_theme_support('custom-logo') to enable logo support in themes.register_logo, add_logo_support, or enable_logo_feature do not exist in WordPress core.functions.php:
add_theme_support('custom-logo');
function display_logo() {
the_custom_logo();
}
display_logo();
What will be the output on the site if no logo is set in the Customizer?the_custom_logo() outputs nothing (no image or placeholder).add_theme_support('custom-logo'); in your theme but the logo does not appear on the site. What is the most likely cause?the_custom_logo() in templates.the_custom_logo(), it won't show. Themes support Customizer by default, and no plugin is required for logos.the_custom_logo() in your theme template -> Option Aget_bloginfo('description'), not 'tagline'.if (get_bloginfo('description')) checks if tagline is not empty before echoing it wrapped in <p> tags.' . get_bloginfo('description') . '
'; always echoes tagline even if empty. if (get_bloginfo('name')) { echo '' . get_bloginfo('description') . '
'; } checks site name, not tagline. if (get_bloginfo('tagline') !== '') { echo get_bloginfo('tagline'); } uses wrong key 'tagline' which returns empty string.