Description
fetchStyleEditorSchemas in libs/sdk/client/src/lib/client/page/utils.ts fires on every client-side client.page.get() call — including production/live/preview mode pages. The only guard today is the SSR check (typeof window === 'undefined').
registerStyleEditorSchemas (called downstream in @dotcms/uve) already returns early when not in UVE_MODE.EDIT, but by that point the network round-trip to /api/v1/page/{pageId}/contenttype-schema has already been paid.
Why it can't simply use getUVEState()
@dotcms/client intentionally does not depend on @dotcms/uve. Importing getUVEState() or UVE_MODE from @dotcms/uve would create a coupling violation.
Proposed fix
Add an inline iframe + mode check in fetchStyleEditorSchemas (same logic as getUVEState(), self-contained):
// Not in a UVE iframe context — schemas are irrelevant
if (window.parent === window) {
return [];
}
// Not in edit mode — schema registration is a no-op downstream anyway
const uveMode = new URL(window.location.href).searchParams.get('mode');
if (uveMode !== 'edit') {
return [];
}
This eliminates the wasted round-trip in production and preview mode without introducing a dependency on @dotcms/uve.
Long-term fix
Include schemas in the GraphQL page response (as noted by @rjvelazco in PR #35355) so no separate HTTP request is needed at all.
Affected file
core-web/libs/sdk/client/src/lib/client/page/utils.ts — fetchStyleEditorSchemas function (around line 280)
Acceptance Criteria
Additional Context
Identified during review of PR #35355 (style editor schema unification). The registerStyleEditorSchemas downstream guard already prevents side effects, but the HTTP request itself is wasted. This is a performance optimization, not a correctness fix.
Description
fetchStyleEditorSchemasinlibs/sdk/client/src/lib/client/page/utils.tsfires on every client-sideclient.page.get()call — including production/live/preview mode pages. The only guard today is the SSR check (typeof window === 'undefined').registerStyleEditorSchemas(called downstream in@dotcms/uve) already returns early when not inUVE_MODE.EDIT, but by that point the network round-trip to/api/v1/page/{pageId}/contenttype-schemahas already been paid.Why it can't simply use getUVEState()
@dotcms/clientintentionally does not depend on@dotcms/uve. ImportinggetUVEState()orUVE_MODEfrom@dotcms/uvewould create a coupling violation.Proposed fix
Add an inline iframe + mode check in
fetchStyleEditorSchemas(same logic asgetUVEState(), self-contained):This eliminates the wasted round-trip in production and preview mode without introducing a dependency on
@dotcms/uve.Long-term fix
Include schemas in the GraphQL page response (as noted by @rjvelazco in PR #35355) so no separate HTTP request is needed at all.
Affected file
core-web/libs/sdk/client/src/lib/client/page/utils.ts—fetchStyleEditorSchemasfunction (around line 280)Acceptance Criteria
fetchStyleEditorSchemasreturns[]early whenwindow.parent === window(not inside a UVE iframe)fetchStyleEditorSchemasreturns[]early when the URLmodeparam is notedit@dotcms/uveorgetUVEState()is added to@dotcms/clientAdditional Context
Identified during review of PR #35355 (style editor schema unification). The
registerStyleEditorSchemasdownstream guard already prevents side effects, but the HTTP request itself is wasted. This is a performance optimization, not a correctness fix.