bricks_analyze_performance

Phase 5IntermediateRead OnlyComplexity: 5/10
Run a performance audit on a page

Overview

Analyzes a Bricks page for performance metrics including element count, nesting depth, inline CSS size, font count, external scripts, and DOM complexity. Returns metrics alongside optimization suggestions.

This is the dedicated performance analysis tool that provides deeper insights than the general « performance » check in bricks_analyze_page. It measures specific performance indicators that affect page load time and rendering speed.

Use this when you suspect a page is slow or overly complex, or as part of the Phase 5 polish workflow to optimize before publishing.

Key Features

Element Count & Nesting Depth
Measures total element count and maximum nesting depth. High element counts (100+) and deep nesting (10+ levels) indicate opportunities for component extraction and structure simplification.
Inline CSS Analysis
Calculates the total size of inline CSS generated by element settings. Large inline CSS (50KB+) suggests too many inline styles instead of global classes.
Font & Script Audit
Counts unique font families, font weights, and external scripts loaded on the page. Multiple fonts and excessive scripts significantly impact load time.
DOM Complexity Score
Provides an overall DOM complexity score based on element count, nesting depth, and unique selectors. Includes a rating (good/moderate/heavy) and optimization suggestions.

When to Use

You suspect a page is slow to load or render
You want to check if a page has too many elements or excessive nesting depth
You need to audit how many fonts, external scripts, or inline styles are on a page
You are optimizing pages before launch for Core Web Vitals
You want specific performance metrics rather than general quality findings
Prerequisites
The target page must exist and contain Bricks elements
Bricks Builder version 1.9 or higher

When NOT to Use

You want image-specific optimization — use bricks_optimize_images instead
You want a general quality audit — use bricks_analyze_page with all checks
You want to check real-world page speed — use external tools like Lighthouse or PageSpeed Insights

Parameters

1 Total Parameters1 Required

Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
page_idnumberREQUIRED
The WordPress page (post) ID to analyze for performance.

Code Examples


Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12

Check page performance

Analyzes performance metrics for the homepage.

JSON
bricks_check_performance({
  page_id: 33
})
// Returns:
// {
//   metrics: {
//     element_count: 85,
//     max_nesting_depth: 7,
//     inline_css_size: 12400,
//     font_count: 2,
//     font_weight_count: 4,
//     external_script_count: 3,
//     dom_complexity_score: 42
//   },
//   rating: "moderate",
//   suggestions: [
//     { message: "Consider extracting 12 inline styles to global classes", priority: "high" },
//     { message: "Reduce font weights from 4 to 2-3 for faster loading", priority: "medium" }
//   ]
// }

Common Mistakes


Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 1935

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Pages with 100+ elements should be reviewed. Often, repeated card patterns can be extracted into components, and unnecessary wrapper divs can be removed with bricks_fix_audit_issues optimize_nesting.

Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 1935

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
This tool measures structural complexity, not actual load time. A page with many elements can still load fast with proper caching, CDN, and optimization plugins. Use this as a complement to Lighthouse/PageSpeed Insights.

Tips & Warnings

Tips & Warnings

Tip: Target these thresholds for optimal performance: element count under 80, nesting depth under 8, inline CSS under 30KB, font count under 3, external scripts under 5.

Tip: The biggest performance win is usually extracting inline styles to global classes. If inline CSS is high, run bricks_audit_site with the duplicate_styles check to find consolidation opportunities.

Warning: DOM complexity is a proxy metric. The actual performance impact depends on the browser, device, and total page weight including images, fonts, and third-party scripts.

Return Values

FieldTypeDescription
metricsobjectPerformance metrics: element_count, max_nesting_depth, inline_css_size (bytes), font_count, font_weight_count, external_script_count, dom_complexity_score.
suggestionsarrayArray of optimization suggestions based on the metrics, with priority ranking and estimated impact.
ratingstringOverall performance rating: good (green), moderate (yellow), heavy (red).

Related Tools

Technical Details

Tool ID
bricks_analyze_performance
API Endpoint
/analysis/page
HTTP Method
POST
Namespace
analysis
Source File
analysis/performance.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release with element count, nesting depth, inline CSS, font/script audit, and DOM complexity scoring.
20250101