Optimizer and assets
Nucleo loads only the CSS and JS of the blocks on the page, and applies rules to plugin and theme assets.
On this page
01Overview
The front end enqueues only the CSS and JS of the blocks present in a Nucleo document. The compiler writes the list in the post metadata. On top of this base, the runtime applies a table of rules to all the styles and scripts in the queue, including those of plugins and themes. The table is the asset-rules artifact. It is compiled from the user's rules and from default rules for form modules and WooCommerce. The audit (Pro) measures the assets loaded by each template type and suggests rules. The purger (Pro) reduces third-party stylesheets to the CSS that can match the page DOM. The reduced variants end up in the same asset-rules artifact. Critical CSS goes inline in the page. With a published critical CSS, the local stylesheets move to a loader that does not block rendering. The optimization from the Performance panel (Pro) combines reduction and critical CSS: it measures in the administrator's browser, computes a candidate, checks it and publishes only the parts without differences. The public site does not check the license: published rules, reduced variants and critical CSS stay active even without a license.
Template key: rules, reduced variants and critical CSS use the key of the current template: 404, search, home, page, single, product, single-<post_type>, archive. With WooCommerce and the Pro package, product, cart, checkout, account and product-archive are added. The object key is <post_type>:<ID>, for example page:12.
02Loading assets on the front end
Assets of Nucleo documents
What it does: on a single page built with Nucleo, it enqueues the stylesheets and scripts listed in the page metadata. It removes duplicates by src: the first occurrence wins. Stylesheets get the handle nucleo-<8 characters of the MD5 of the URL>. eager scripts go to the footer with defer. Scripts with the visible, interaction or idle strategy go to the nucleo-loader loader through window.ncLazy.
How to use it: automatic. The site's CSS tokens go inline on the handle nucleo-tokens, enqueued first.
Parameters: none.
Permissions: none, it is the public front end.
Edition: Free
Known limits: the emergency mode (constant NUCLEO_SAFE_MODE or option nucleo_safe_mode) turns off all Nucleo assets and also the asset rules. The loader activates visible and interaction on every .nc-<type> element of the page and loads the script once; without those elements the script does not start. The idle strategy looks for no element: it starts when the browser is idle, or after 200 ms where that function does not exist.
Preload of the main font
What it does: sends one HTTP header Link: <url>; rel=preload; as=font; type="font/woff2"; crossorigin for each font to preload, up to two URLs without duplicates: the font file of $font.body at normal weight 400 (if present, otherwise the first file of the family or the first installed font) and the heading font file at weight 700, if present.
How to use it: automatic. The URL is saved in the preload key of the tokens artifact. Local fonts and fallbacks: see the Design token chapter.
Parameters: none.
Permissions: none.
Edition: Free
Known limits: at most two files. Only on single pages with Nucleo metadata. If the headers have already been sent, the preload is not sent.
Applying the rules
What it does: on wp_enqueue_scripts, at priority 9999, it reads the asset-rules artifact and applies the table to the queue of styles and scripts. Order: dequeue and replace on styles, replacement with the reduced variants, rules on scripts, then the critical CSS. It repeats the variant replacement and the loader handover on wp_print_styles and wp_print_footer_scripts (priority 1), for stylesheets enqueued late.
How to use it: automatic on every front-end page, even if not built with Nucleo. The artifact store is in wp-content/uploads/nucleo/store (generation folder), with a fallback on options.
Parameters: none.
Permissions: none.
Edition: Free. No edition check.
Known limits: without the asset-rules artifact it applies no rules and no variants, but it still applies the critical CSS. Handles are looked up by the same name among styles and scripts: a rule on foo applies to the style and to the script foo. The defer action has no effect on styles.
CSS preview (?nucleo_css=)
What it does: generates the page in a comparison mode.
original: no reduced variants and no critical CSS.candidate: variants and critical CSS of the candidate that is not published.critical: only the critical CSS of the candidate, without local stylesheets and without the loader.published: like the front end, but without loading the full CSS.
With an active preview, the page is generated as for a visitor, without the admin bar and without the empty checkout redirect.
How to use it: https://site/page/?nucleo_css=candidate, from a logged-in user. The Performance screen uses it.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
nucleo_css | query string | original, candidate, critical, published | none | Other values: no preview. |
Permissions: manage_options. For other users the parameter is ignored.
Edition: Free. The candidate is produced only with the Pro abilities.
Known limits: no nonce, by choice (read-only preview). A change of user during the request closes the preview.
03Rules per handle
Rule format
What it does: describes what to do with a WordPress handle (style or script) for a template or for a single object. The rules are compiled into a table by key and handle. Invalid rules are ignored. A page:<slug> or post:<slug> that matches no page or post skips the rule and produces a warning. With several rules on the same key and the same handle, the last one wins.
How to use it: JSON list passed to nucleo/assets-rules-set. Example:
[
{"action": "dequeue", "handle": "contact-form-7", "templates": ["*"], "except": ["page:12"]},
{"action": "defer", "handle": "plugin-x-analytics", "strategy": "async"},
{"action": "replace", "handle": "swiper-old", "with": "swiper"}
]Parameters:
| Name | Type | Allowed values | Default | Notes | |
|---|---|---|---|---|---|
action | string | dequeue, defer, replace | required | Other value: rule ignored. | |
handle | string | not empty | required | Handle registered in WordPress. | |
templates | array of strings | *, template key ([a-z0-9][a-z0-9-]*), object key (type:ID) | ["*"] | If present it cannot be empty. Pattern: `^(\*\ | [a-z0-9][a-z0-9-]*)(:\d+)?$`. |
except | array of strings | same pattern as templates | [] | Templates or objects where the rule does not apply. | |
strategy | string | defer, async, interaction, idle | defer | Only with action: defer. | |
with | string | non-empty handle | required with replace | Handle to enqueue in place of the removed one. |
Permissions: see nucleo/assets-rules-set.
Edition: Free
Known limits: at publication page:<slug> and post:<slug> become page:<ID> and post:<ID>. If the slug does not exist the rule is skipped and the message appears in nucleo_asset_rules_warnings. An element with an invalid form in templates or except discards the whole rule.
Resolution and precedence
What it does: for each handle in the queue, it looks for the entry in this order: object key, template key, *. An entry whose except contains the current template or object does not apply and passes to the next level. A dequeue that would remove a handle on which another handle still in the queue depends does not apply: the rule ends up among the blocked rules, which the runtime ignores.
How to use it: automatic.
Parameters: none.
Permissions: none.
Edition: Free
Known limits: replace always removes the handle. It enqueues with only if it is registered; otherwise it is equivalent to a dequeue, without dependency checks. defer with interaction or idle sets strategy: defer and adds the attribute data-nc-load="<strategy>" to the tag. The tag becomes <script type="text/plain"> with data-nc-src, and the loader activates it: interaction at the first user gesture (pointerdown, keydown, scroll or touchstart), idle when the browser is idle or after 2 seconds. With at least one delayed script, Nucleo enqueues the loader, also on a page without lazy blocks. A script with queued dependents or with inline scripts is not delayed: it stays defer.
Default rules
What it does: Nucleo places two groups of default rules before the user's rules. A user rule on the same key and handle replaces them.
- Form modules:
dequeueon*of the assets of Contact Form 7 (contact-form-7,swv), Gravity Forms (gform_gravityforms,gform_json), WPForms (wpforms-full), Fluent Forms (fluent-form-styles,fluent-form-submission).exceptcontains the pages that depend onform:<plugin>. - WooCommerce (Pro package only, with WooCommerce active):
dequeueon*ofwoocommerce-general,woocommerce-layout,woocommerce-smallscreen,wc-blocks-style,woocommerce,wc-add-to-cart,wc-order-attribution,sourcebuster-js,woocommerce-inline, exceptproduct,product-archive,cart,checkout,account. Alsodequeueofwc-cart-fragmentseverywhere, unless the optionnucleo_woo_fragments=keep.
How to use it: automatic.
Parameters: setting performance.wooFragments (keep or off) of nucleo/settings-set.
Permissions: none to apply them.
Edition: form modules Free. WooCommerce: requires the files of the Pro package, without a license check.
Known limits: the default rules do not appear among the user's rules or in the rules field of the report.
Publishing the table
What it does: saves the user's rules in the option nucleo_asset_rules (autoload false) and rewrites the asset-rules artifact as { table, purged }. It keeps the reduced variants already produced. The warnings of the last publication are kept in the option nucleo_asset_rules_warnings (autoload false).
How to use it: nucleo/assets-rules-set, site import (rules/assets.json, see the WP-CLI commands chapter). It also republishes when a plugin is activated or deactivated, after a document is changed and when the store is rebuilt.
Parameters: none.
Permissions: those of the entry point.
Edition: Free
Known limits: publishing replaces all the user's rules. There is no partial save.
nucleo/assets-rules-set
What it does: replaces the user's asset rules and republishes the table. It records the assets-rules-set event in the activity log.
How to use it: ability, or Performance → Rules tab (Pro). From the command line:
# replaces the asset rules with the given user
wp nucleo ability run assets-rules-set --input='{"rules":[...]}' --user=adminThe full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
rules | array | list of rules (see Rule format) | required | Not a list: WP_Error invalid_input. |
Permissions: manage_options; OAuth scope nucleo:design.
Edition: Free
Known limits: returns { ok: true, count, warnings }. count is the number of rules received, valid or not. warnings is the list of texts describing the skipped rules (for example a page:<slug> that does not exist).
04Asset audit
The features in this section are part of the Pro package.
Audit per template
What it does: schedules a job for each sample template and runs them one at a time in WP-Cron (nucleo_asset_audit), 10 seconds apart. Each job makes a loopback request to the sample page with a signed token. The token activates the capture of the styles and scripts in the queue at the end of the page.
How to use it: nucleo/assets-audit, or Performance → Audit tab (Pro).
Parameters: see nucleo/assets-audit. Sample URL per template:
| Template | URL |
|---|---|
home | home_url('/') |
page | last published page, otherwise the home |
single | last published post, if any |
archive | first non-empty category, if any |
search | /?s=nucleo |
404 | /nucleo-page-not-found/ |
product | last product (with WooCommerce) |
product-archive | Shop page, otherwise first product category (with WooCommerce) |
cart, checkout, account | WooCommerce pages |
Permissions: see nucleo/assets-audit.
Edition: Pro
Known limits:
- Request timeout: 20 seconds. The token is valid for 10 minutes and signed with HMAC-SHA256 using
wp_salt('auth'). - The request verifies the SSL certificate when the URL is on the site's domain or on localhost. The sample URLs are on the site's domain: a site with an invalid certificate produces a failed job.
- If the site cannot reach itself, the job ends in
failedwith the error message or the HTTP code. - The old keys
post,categoryandproduct_catare read assingle,archiveandproduct-archivein the audit jobs and in the stored reduced variants. - A new start replaces the previous plan and resets the completed and failed jobs.
Data saved by the audit
What it does: saves the plan status and the asset registry.
- Option
nucleo_asset_audit(autoloadfalse):{ jobs, done, failed }. - Transient
nucleo_capture_<job>for one hour: the raw capture. - Option
nucleo_asset_registry(autoloadfalse): per template{ styles, scripts, url, date }. Each asset hashandle,src,origin,hash(SHA-1),size,gzipandlibrary.
How to use it: read with nucleo/assets-report.
Parameters: none.
Permissions: none (internal data).
Edition: Pro
Known limits: the registry keeps only local files (under ABSPATH or WP_CONTENT_DIR). External assets are discarded. origin is plugin:<folder>, theme:<folder>, core, nucleo or external. The gzip value reaches the report only when known.
Library detection
What it does: recognizes a library from its banner (first 2 KB of the file) or from its path. It returns name@version. Known libraries: jquery-ui, jquery, swiper, slick, bootstrap, fontawesome, lodash, gsap, owl-carousel, select2, flatpickr, lightbox, magnific-popup, isotope, masonry, aos, animate.css.
How to use it: automatic during the audit.
Parameters: none.
Permissions: none.
Edition: Pro
Known limits: versions only in the X.Y.Z format.
Asset report
What it does: builds the report from the registry.
assets: per handlesrc,origin,hash,size,gzip(when known),library,templates.duplicates: groups of handles with the same hash.versions: libraries present in more than one version.templates: per templatebytes,styles,scripts,cssBytes,jsBytes,url,dateandheaviest(the three heaviest files).suggestions: adequeuefor each duplicate beyond the first (alphabetical order), with the templates where it appears; areviewfor each library in more than one version.
How to use it: nucleo/assets-report, which adds audited, pending, failed, rules (the active user rules), urls and warnings. Performance → Assets tab (Pro).
Parameters: none.
Permissions: manage_options; OAuth scope nucleo:read.
Edition: Pro
Known limits: size is the uncompressed size. The report does not identify assets that are "loaded but not needed". The reason of a dequeue is a fixed Italian string (duplicato di <handle> (stesso hash)), not translated.
nucleo/assets-audit
What it does: schedules the audit of the sample templates, all of them or the ones indicated.
How to use it: ability. From the command line: wp nucleo ability run assets-audit --user=admin. The full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
templates | array of strings | ^[a-z0-9_-]{1,40}$, at most 20 | [] (all) | Names outside the list of samples are ignored. |
Permissions: manage_options; OAuth scope nucleo:design.
Edition: Pro
Known limits: no valid template produces { ok: false, error: { code: "no_templates" } }. The result { ok: true, jobs } only shows the scheduled jobs: the outcome arrives later, with nucleo/assets-report.
05Third-party CSS reduction (purger)
The features in this section are part of the Pro package.
Purger
What it does: removes from a CSS stylesheet the rules that cannot match the DOM. The DOM is read from the HTML: tags, classes, IDs and attribute names.
- Keeps a rule if at least one selector can match. Removes from the rule only the impossible selectors.
- Ignores the content of
:is(),:where(),:has(),:not()and simple pseudo-classes; checks the rest. - Always keeps selectors with escapes (
\) or::selection, and those with a class that starts with an entry of the safelist. - Keeps intact the rules with custom properties (
--x). - Filters inside
@media,@supportsand@layer; removes the blocks left empty. Other at-rules (for example@font-face) stay intact. - Removes the
@keyframesnot referenced byanimationoranimation-namein the remaining rules.
How to use it: internal. Used by nucleo/css-purge and nucleo/css-optimize.
Parameters: none.
Permissions: none.
Edition: Pro
Known limits: a CSS that the parser cannot analyze comes back whole. Compact output.
Safelist
What it does: list of class prefixes that the purger always keeps. Defaults: is-open, active, show, open, select2-, added, loading, processing, blockUI, woocommerce-message, woocommerce-error, woocommerce-info, woocommerce-notices-wrapper, wc-block-components-notice, woocommerce-invalid, woocommerce-validated, wc-variation-selection-needed, woocommerce-variation. The entries of the option nucleo_purge_safelist are added.
How to use it: nucleo/settings-set with { "settings": { "performance": { "purgeSafelist": ["my-state"] } } }, or Performance → Optimization tab, Safelist panel (one class per line). Read with nucleo/settings-get.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
performance.purgeSafelist | array of strings | class prefixes; .name for the exact class, #id for the exact ID | [] | Spaces removed, empty and duplicate entries deleted. The option also accepts a string separated by spaces or commas. |
Permissions: manage_options; OAuth scope nucleo:admin (settings-set).
Edition: Free for the setting. It has an effect only with the Pro reduction features.
Known limits: for entries without a prefix the comparison is "the class starts with the entry". An entry with the dot (.is-open) matches the exact class; an entry with # (#bar) matches the exact ID. Complex selectors are not supported, even though the description of settings-set speaks of "selectors".
nucleo/css-purge
What it does: reduces the indicated stylesheets for a template type on the HTML of a sample page. It writes uploads/nucleo/purged/<handle>.<template>.<sha1 8>.css, rewrites the relative url() and @import as absolute, and records the variant in the template's asset rules. The site serves the variant in place of the original stylesheet.
How to use it: ability. Example input: {"template":"page","handles":[{"handle":"plugin-x","src":"https://site/wp-content/plugins/x/style.css"}]}. The full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
template | string | ^[a-z0-9][a-z0-9-]*$ | required | Must be a template key, otherwise the variant is never served. |
handles | array of objects | handle (^[A-Za-z0-9_][A-Za-z0-9_.-]*$), non-empty src | required |
Permissions: manage_options; OAuth scope nucleo:design.
Edition: Pro
Known limits:
- Sample page: last published post for
page,single(article) andproduct; the home for the other templates. One page, anonymous request, with a timeout of 15 seconds. - Errors in the result
{ ok: false, error: { code } }:sample_unreachable(the page does not return 200),dir_unwritable,write_failed. - Handles with a non-local
srcare skipped without error. - Classes added by JavaScript are not seen: they need the safelist or the optimization from the panel.
- Cancellation:
nucleo/css-optimize-offon the same template. After each successfulnucleo/css-purge, the.cssfiles inuploads/nucleo/purgedthat are no longer referenced are deleted;nucleo/css-optimize-offdoes not delete them, they stay until the nextnucleo/css-purge.
Serving the reduced variants
What it does: on the front end it replaces the src of an enqueued stylesheet with the variant of the current template. It serves the variant only if the file is under the uploads folder.
- Default mode: after the first
pointerdown,keydownorscroll, an inline script (handlenucleo-full-css) adds the links to the original CSS. strictmode (optionnucleo_purge_mode=strict): the original CSS is never loaded.
How to use it: automatic. The mode is chosen with nucleo/settings-set, { "settings": { "assets": { "purgeMode": "strict" } } }, or "normal" to return to the default mode.
Parameters: setting assets.purgeMode of nucleo/settings-set (normal or strict), saved in the option nucleo_purge_mode.
Permissions: manage_options; OAuth scope nucleo:admin (settings-set).
Edition: Free. The runtime does not check the edition.
Known limits: in the ?nucleo_css= previews the original CSS is not loaded.
06Critical CSS
Saving and using the critical CSS
What it does: keeps a critical CSS per template in the critical artifact ({ template: css }). On the front end it prints it inline on the handle nucleo-tokens. Then it removes from the queue all the stylesheets with a local file (Nucleo and third-party, dependencies included, in print order) and hands them to the loader through window.nucleoCss. The loader inserts them right after the inline style with media="print" and sets their own media on load. The inline style of each removed stylesheet stays in the page with the handle <handle>-nc-inline.
With the critical CSS active, the local stylesheets depend on the loader's JavaScript. No <noscript> is provided.
How to use it: nucleo/critical-set, nucleo/css-optimize-apply, the local CLI nucleo critical, external service.
Parameters: none.
Permissions: those of the entry point.
Edition: Free
Known limits:
- Limit of 50 KB (51200 bytes) after the removal of
</style. - Fallback: without critical CSS for the template, the page loads the stylesheets normally with blocking
<link>tags. - External stylesheets (CDN) stay normal
<link>tags.
nucleo/critical-set
What it does: saves the critical CSS of a template and replaces the previous one.
How to use it: ability. It is used by the local CLI, by the external service (callback) and by the "Critical CSS" panel of the Optimization tab, where the CSS is pasted by hand. The full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
template | string | not empty | required | No format check. Must be a template key to have an effect. |
css | string | up to 50 KB | required | </style removed. |
Permissions: edit_theme_options; OAuth scope nucleo:design.
Edition: Free
Known limits: over 50 KB or empty template: WP_Error invalid_critical_css. Wrong types: WP_Error invalid_input. Result { ok: true, bytes }. It does not update the state of nucleo/css-status.
nucleo/critical-request
What it does: asks an external service to compute the critical CSS. It sends POST <url>/v1/jobs with Authorization: Bearer <key> and body { site, templates: [{ template, url }], callback }. callback is the REST URL of nucleo/critical-set.
How to use it: ability, or the "Request from service" button of the Optimization tab. Configuration with nucleo/settings-set, group service (url, key), saved in the option nucleo_service. The full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
templates | array of strings | 1–64 characters each, at least one | home, page, single, product, archive, search, 404 |
Permissions: edit_theme_options; OAuth scope nucleo:design.
Edition: Free for the ability. The Settings → Service tab is Pro.
Known limits:
- URL not
https://or empty key:WP_Errorservice_not_configured. Network error:service_unreachable. Response not 2xx:service_error. Timeout of 15 seconds. - Sample URLs: last published post for
page,singleandproduct; the home for all the other templates, includingarchive,searchand404.
Local CLI nucleo critical
What it does: opens each URL with Playwright (Chromium), measures the CSS coverage and writes <template>.css with only the used ranges of each stylesheet. Without --no-push it sends each file to nucleo/critical-set.
How to use it:
# computes the critical CSS for two templates and sends it to the site
nucleo critical --urls home=https://site.it/,page=https://site.it/about/ [--out critical] [--no-push]Basic authentication (user and Application Password) towards the Abilities API. Details in the local CLI chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
--urls | string | template=url separated by commas | none | Splits each pair at the first =. Without it, reads urls from nucleo/assets-report (Pro). |
--out | string | folder | critical | |
--no-push | flag | absent | Writes the files only. |
Permissions: edit_theme_options to send; manage_options to read the report.
Edition: Free with --urls. Without --urls it requires nucleo/assets-report (Pro).
Known limits:
- Without
--urls, an entry ofurlswithout an absolute URL ends up among the skipped ones. Without any URL the command prints "no URL to analyse" and exits with 1. - A
--urlspair without=, without a template or without a URL is a usage error, before any call. - The critical CSS collects the rules that match the elements of the first screen in four viewports: 390×844, 820×1180, 1440×900 and 2560×1440. It stops at 50 KB. If
nucleo/critical-setrejects the CSS, the command stops with the site's message.
07Optimization from the panel
The features in this section are part of the Pro package.
Optimization flow
What it does: for a template type, it runs these steps in the administrator's browser:
Takes up to 5 sample URLs from the CSS state.
Opens each URL in a hidden iframe with ?nucleo_css=original, at 1280×800 (desktop) and 390×844 (mobile). It observes for 3 seconds the classes added by JavaScript. It marks the elements of the first screen, including the hidden children of a first-screen element: with no area or moved off screen, such as a skip link with left:-9999px.
Sends the HTML, the HTML of the first screen and the classes to nucleo/css-optimize.
Compares the original page with ?nucleo_css=candidate (all the elements) and with ?nucleo_css=critical (first screen only), on the first 2 pages and on both viewports. It compares position, measures and main styles, with a tolerance of 2 px, up to 1500 elements.
Calls nucleo/css-optimize-apply with purge true only if no candidate comparison has differences, and critical true only if no critical comparison has any.
How to use it: Performance → Optimization (page nucleo-performance).
Parameters: none.
Permissions: edit_theme_options for the page; the abilities require manage_options.
Edition: Pro (page with 'edition' => 'pro' in the registry).
Known limits: loading timeout of each iframe: 30 seconds. It keeps at most 20 differences.
Sample pages
What it does: lists up to 5 URLs per template, with the template keys: home, page (the static front page excluded), single, archive (non-empty categories), search, 404. With WooCommerce: product, product-archive (Shop page first), cart, checkout, account. It keeps only the templates with at least one URL.
How to use it: internal, exposed by nucleo/css-status in the urls field.
Parameters: none.
Permissions: none.
Edition: Pro
Known limits: no samples for custom post types (single-<type>).
nucleo/css-optimize
What it does: computes the candidate of a template. It reads the local stylesheets <link rel="stylesheet" id="<handle>-css"> of the samples, one per handle. It reduces the third-party stylesheets on the DOM merged from all the samples, with the safelist and the classes received. It leaves the nucleo-* stylesheets intact. It excludes admin-bar and dashicons. It writes the reduced files to uploads/nucleo/purged. It computes the critical CSS by reducing all the concatenated stylesheets on the DOM of the first screen, without safelist; a stylesheet with its own media goes inside its @media. It saves the candidate, without publishing it.
How to use it: ability, called from the panel. The full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
template | string | ^[a-z0-9][a-z0-9-]*$ | required | |
samples | array of objects | 1–10 entries { url, viewport, html, fold } | required | url on the same host as the site; viewport desktop or mobile; html not empty up to 3 MB; fold up to 3 MB, can be empty. |
classes | array of strings | at most 2000, each 1–200 characters | [] | Classes seen in the browser, added to the safelist. |
Permissions: manage_options; OAuth scope nucleo:design.
Edition: Pro
Known limits: the result contains candidateId, to pass to nucleo/css-optimize-apply. Errors in the result { ok: false, error: { code } }: no_stylesheets, dir_unwritable, write_failed. Critical CSS over 50 KB: candidate.critical.error = critical_too_big and no critical CSS. Without elements in the first screen the critical CSS is not computed. Invalid input: WP_Error invalid_input.
nucleo/css-optimize-apply
What it does: publishes the chosen parts of the candidate and removes the candidate. It first removes all the reduced variants of the template. With purge it records the variants of the candidate. With critical and a critical CSS in the candidate it saves it; otherwise it deletes the critical CSS of the template. It saves the state entry in the option nucleo_css_status (autoload false), with the MD5 fingerprints of the source stylesheets.
How to use it: ability, called from the panel. The full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
template | string | ^[a-z0-9][a-z0-9-]*$ | required | |
purge | boolean | required | Publishes the reduced stylesheets. | |
critical | boolean | required | Publishes the critical CSS. | |
check | object | { elements: integer >= 0, diffs: list of objects } | { elements: 0, diffs: [] } | At most 20 diffs are kept. |
candidateId | string | 40 hexadecimal characters | required | The id returned by nucleo/css-optimize. |
Permissions: manage_options; OAuth scope nucleo:design.
Edition: Pro
Known limits: if the saved candidate is not the one with candidateId, for example because another measurement replaced it, the call returns candidate_changed and publishes nothing. A candidate measured before a site change gives candidate_stale: measure it again. Resulting state active (reduction published and critical CSS published or absent in the candidate), partial (only one of the two) or failed (neither). Without a candidate: { ok: false, error: { code: "no_candidate" } }. Critical CSS over 50 KB: critical_too_big.
nucleo/css-optimize-off
What it does: turns off reduction and critical CSS of a template. It removes the variants from the asset-rules artifact and the critical CSS from the critical artifact. It keeps the state entry with state: off.
How to use it: ability, or the turn-off button in the Optimization tab. The full entry is in the write abilities chapter.
Parameters:
| Name | Type | Allowed values | Default | Notes |
|---|---|---|---|---|
template | string | ^[a-z0-9][a-z0-9-]*$ | required |
Permissions: manage_options; OAuth scope nucleo:design.
Edition: Pro
Known limits: it also cancels the variants created with nucleo/css-purge and the critical CSS saved with nucleo/critical-set. It does not delete the files in uploads/nucleo/purged: they stay until the next nucleo/css-purge.
nucleo/css-status
What it does: returns one entry for each template of the samples. States: none (never optimized), off, active, partial, failed. stale is true if an active or partial entry has a source stylesheet that changed (different MD5) or is no longer found. When the site changes after the measurement, the plugin withdraws the published optimization: the entry becomes off with reason: site_changed and the public site goes back to the original stylesheets, without critical CSS. Site changes are: saving a document, publishing the tokens, updating or activating a plugin and switching theme.
How to use it: ability. The full entry is in the read abilities chapter.
Parameters: none.
Permissions: manage_options; OAuth scope nucleo:design.
Edition: Pro
Known limits: templates that were optimized but are no longer among the samples do not appear.
08Compilation of document styles
Style compiler
What it does: turns the styles of the nodes into minified CSS and one class per node. Order of the output: base rules and style.custom, one @media (min-width) block per breakpoint, one @container block for the descendants of a node with settings.responsiveMode: "container", the visibility rules per breakpoint (display:none!important), the @keyframes of the presets used, and a @media (prefers-reduced-motion:reduce) rule that turns off animations and transitions.
- Nodes with the same normalized style share the class
nc-h<sha1 6>. The others getnc-<scope><id>; an id without digits takes the prefixn-. - The tokens (
$group.name) are resolved also in composite values. An unknown token discards the declaration. style.parts.<part>accepts only the keys of the groupssize,spacing,typography,color,border,effects,layout,motion, and only for the parts declared by the block.style.custom: a selector that starts with&and uses safe characters; property^-{0,2}[a-z][a-z0-9-]{0,60}$; values withouturl(.
How to use it: internal to the compiler. Schema details in the schema and blocks chapter, and in the compiler and runtime chapter.
Parameters: default breakpoints base 0, md 768, lg 1024, xl 1920 px (mobile first).
Permissions: none.
Edition: Free
Known limits: invalid values are discarded silently, also during compilation.
Style keys
What it does: maps the camelCase keys of the documents to CSS properties, by group.
spacing:padding,margin,gap.size:width,maxWidth,minWidth,maxHeight,minHeight,height,aspectRatio.color:color,background,accentColor.typography:fontSize,fontWeight,lineHeight,letterSpacing,fontFamily,fontStyle,textAlign,textDecoration,textTransform,whiteSpace.layout:display,columns,direction,wrap,justify,align,order,flexGrow,flexShrink,flexBasis,alignSelf,justifySelf.border:border,borderTop,borderRight,borderBottom,borderLeft,borderRadius,boxShadow.effects:opacity,objectFit,filter,transform.position:position,top,right,bottom,left,inset,zIndex,scrollMarginTop,overflow,overflowX,overflowY.menu(nc/menu):itemColor,itemColorHover,itemColorActive,itemBackground,itemBackgroundHover,itemBackgroundActive,itemDecoration,itemDecorationHover,itemWeight,itemWeightActive,itemPadding,itemRadius,itemGap,submenuBackground,panelWidth,panelBackground.motion:animation,animationDuration,animationDelay,transition.- Parts of the interactive blocks: groups
controls,buttons,choices,carousel,link,results,fields. Each key writes a--nc-*variable on the node. - States: the keys
color,background,border,borderTop,borderRight,borderBottom,borderLeft,boxShadow,opacity,filter,fontWeightandtextDecorationaccept the suffixesHover(:is(:hover,:focus-within)) andCurrent(.is-current).
How to use it: keys in style of the nodes.
Parameters: main allowed values:
| Key | Allowed values |
|---|---|
position | static, relative, absolute, sticky, fixed |
overflow, overflowX, overflowY | visible, hidden, clip, scroll, auto |
textDecoration, itemDecoration, itemDecorationHover | none, underline, line-through, overline |
textTransform | none, uppercase, lowercase, capitalize |
whiteSpace | normal, nowrap, pre-line |
fontStyle | normal, italic, oblique |
alignSelf, justifySelf | auto, normal, stretch, center, start, end, flex-start, flex-end, self-start, self-end, baseline |
zIndex, order | integer from -9999 to 9999 |
flexGrow, flexShrink | number >= 0 |
filter | only grayscale(N), N between 0 and 1 or between 0% and 100% |
resultsColumns | integer from 1 to 12, becomes repeat(N,minmax(0,1fr)) |
columns | integer >= 1 becomes repeat(N,minmax(0,1fr)); a string stays as it is |
linkDecoration, linkDecorationHover | none, underline, inherit |
navJustify | flex-start, center, flex-end, space-between |
Permissions: none.
Edition: Free
Known limits: a number receives px, except for properties without units (font-weight, line-height, opacity, order, flex-grow, flex-shrink, z-index, column-count and every property ending in -weight). Values with ;, {, }, <, >, \, control characters, /* or */ are discarded.
Animations and transitions
What it does: handles the motion group.
animation: presetsfade-in,slide-up,pop,spin,pulse,shimmer,progress, ornone. Each preset uses the keyframesnc-k-<name>.animationDuration,animationDelay:0.8s,800msor a number (milliseconds).transition:<property> <duration> [easing] [delay], several entries separated by commas. Propertyallor a CSS name. Easingease,linear,ease-in,ease-out,ease-in-out.
How to use it: keys in style of the nodes or parts.
Parameters: see above.
Permissions: none.
Edition: Free
Known limits: an invalid value produces no declarations. Transitions accept only the listed easings, not cubic-bezier().
09Hooks and filters
Hooks used by the system
What it does: the system defines no public filters or actions of its own. It uses these WordPress hooks:
wp_enqueue_scripts(priority 9999): applying the rules.wp_print_styles,wp_print_footer_scripts(priority 1): late stylesheets.wp_print_footer_scripts(priority 9999): audit capture.script_loader_tag: thedata-nc-loadattribute.activated_plugin,deactivated_plugin,nucleo/document_saved(priority 20): republishing the table.nucleo_asset_audit(cron event): next audit job.nucleo/pro: decides the edition (see below).
How to use it: no dedicated extension point.
Parameters: none.
Permissions: none.
Edition: Free
Known limits: none found.
10Expired license
Behavior without an active license
What it does: without a license the Pro edition is not active. The Pro abilities (nucleo/assets-audit, nucleo/assets-report, nucleo/css-purge, nucleo/css-status, nucleo/css-optimize, nucleo/css-optimize-apply and nucleo/css-optimize-off) are not registered. The Performance screen is locked (edition: pro).
- On the front end everything stays active: rules, reduced variants, critical CSS and loading of the full CSS keep working.
- The WooCommerce default rules remain, if the files of the Pro package are installed.
nucleo/assets-rules-set,nucleo/critical-setandnucleo/critical-requestremain available (Free).- An audit already scheduled keeps running in cron: the audit and the capture are registered without an edition check.
- Without a license no ability removes the reduced variants:
nucleo/css-optimize-offis not registered andnucleo/assets-rules-setkeeps the variants. The critical CSS is neutralized withnucleo/critical-setand an emptycss, because the empty string counts as no critical CSS.
How to use it: no action.
Parameters: none.
Permissions: none.
Edition: concerns the Pro package without a license.
Known limits: in the Free package the Pro files are missing. In that case reduction, audit and optimizer are not present, but the site still serves the variants and the critical CSS already published.
Was this page helpful?