bricks_load_custom_cdn

Phase 4.5IntermediateComplexity: 4/10
Load any custom CSS/JS from a CDN URL

Overview

Loads a custom CSS or JS file from any CDN URL. Use this when the library you need is not in the built-in catalog. Injects the appropriate <link> or <script> tag and optional initialization code.

Key Features

Any CDN URL
Load any CSS or JS from any HTTPS CDN URL
Deduplication
Checks for existing URLs before injecting
Init script support
Optional initialization JS wrapped in DOMContentLoaded

When to Use

Loading a library not in the built-in catalog
Adding a specific version of a library
Injecting custom CSS/JS from a third-party CDN
Prerequisites
Have the full CDN URL ready (must start with https://)
Know the asset type (css or js)

When NOT to Use

For libraries in the built-in catalog — use bricks_load_cdn_library instead (handles URLs automatically)
For inline custom code — use bricks_add_custom_css or bricks_add_custom_js

Parameters

5 Total Parameters2 Required3 Optional
urlstringREQUIRED
Full CDN URL (must start with https://)
typeenumREQUIRED
Asset type: css or js
Values: css, js
scopeenumoptional
Where to inject: global or page
Default: global Values: global, page
page_idnumberoptional
Page ID (required for page scope)
init_scriptstringoptional
Optional init JS to run after load

Code Examples

Load a custom JS library

Load a library from a CDN with initialization

JSON
{
    "url": "https://cdn.example.com/lib.min.js",
    "type": "js",
    "scope": "global",
    "init_script": "MyLib.init({ option: true });"
}
Response
{"success": true, "actions": ["✓ Injected JS into global footer", "✓ Injected init script into global footer"]}

Tips & Warnings

Tips & Warnings
  • URL must be HTTPS — HTTP URLs are not supported
  • CSS is injected in the header, JS in the footer with defer
  • Init scripts are wrapped in DOMContentLoaded automatically

Return Values

FieldTypeDescription
successbooleanWhether the CDN asset was loaded successfully
actionsarrayList of actions taken

Related Tools

Technical Details

Tool ID
bricks_load_custom_cdn
API Endpoint
/bricks-mcp/v1/custom-code (multiple calls)
HTTP Method
POST
Namespace
wordpress-site
Source File
wordpress/cdn-libraries.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101