Migration to v2.0.0
Breaking changes
Section titled âBreaking changesâProgrammatic API restructuring
Section titled âProgrammatic API restructuringâThe library has been refactored to provide a more direct and modern API. The previous version exported modules as namespaces, whereas v2.0.0 exports functions and constants directly.
Before (v1):
import { rules, validation } from '@rviscomi/capo.js';
const weight = rules.getWeight(element);const isValid = validation.isValidElement(element);After (v2):
import { getWeight, isValidElement, BrowserAdapter } from '@rviscomi/capo.js';
const adapter = new BrowserAdapter();const weight = getWeight(element, adapter);const isValid = isValidElement(element, adapter);Removal of WebPageTest and BigQuery support
Section titled âRemoval of WebPageTest and BigQuery supportâSupport for WebPageTest and BigQuery has been removed from the core library to reduce maintenance burden and focus on the core analysis engine. This includes the removal of the webpagetest/ and bigquery/ directories.
Removal of Capo.js snippet
Section titled âRemoval of Capo.js snippetâThe standalone Capo.js snippet has been removed. Users are encouraged to use the Chrome extension or the programmatic API.
New features and improvements
Section titled âNew features and improvementsâNew adapter system
Section titled âNew adapter systemâCapo.js now supports a flexible adapter system, allowing it to run on different DOM implementations.
- Built-in adapter: The
BrowserAdapteris provided for standard browser DOM environments. - Custom adapters: Consumers can implement their own adapters by extending the base
AdapterInterfaceclass. This enables Capo.js to work with different parsers (like JSDOM or ASTs), unlocking its use in static analysis tools.
import { BrowserAdapter, analyzeHead } from '@rviscomi/capo.js';
const adapter = new BrowserAdapter();const results = analyzeHead(document.head, adapter);New validation rules
Section titled âNew validation rulesâ- Font preload missing crossorigin: Capo.js now validates that font preloads include the
crossoriginattribute.
Virtual console
Section titled âVirtual consoleâThe demo page now includes a virtual console, making it easier to see Capo output right in the docs, without needing to open the browser console.