-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Summary
The AMPHTML Validator ensures that critical features of the AMPHTML spec are followed within AMP related documents. It is maintained by a set of rules and engines written in C++ and JavaScript that apply those rules during validation. There are many developer tools that utilize these validator engines to assist in the development of valid AMP documents.
Due to ongoing complexity and developer maintenance of two validator engines, the Caching Working Group is deprecating the native JavaScript validator in favor of a WebAssembly validator which uses the C++ engine.
Existing developer tools such as the Validator Web UI, Chrome Extension, VS Code Extension and Node.js Package have already migrated to the WebAssembly validator.
To inform existing developers using validator.js directly and not through one of these developer tools, the APIs in validator.js will be deprecated to return an error message to update tooling to use validator_wasm.js and it will no longer provide validation. This was released for a short time on Monday, September 13, 2021 before being rollbacked. It will be released again on Thursday, September 23, 2021 pending approval here.
Developers unable to migrate to the WebAssembly validator immediately due to compatibility issues, will be able to utilize a temporary fallback to the native JavaScript validator (validator.20211101.deprecated.js). This will be removed on November 1, 2021.
Motivation
The AMPHTML Validator has two implementations. One in C++ and one in JavaScript. These utilize different HTML parsers which at times can cause differences between validation results of documents. Over time these differences have been reduced. However, there is ongoing complexity and maintenance costs in keeping these two implementations in sync. With a WebAssembly validator version released, it is no longer necessary to continue to endure those costs by deprecating the native JavaScript version in favor of the WebAssembly version.
Impact on Existing Users
Developers utilizing validator.js directly from the Google AMP Cache will need to upgrade to using the WebAssembly version (validator_wasm.js). A temporary fallback version is provided until November 1, 2021.
Alternative Implementation
A temporary fallback version is provided until November 1, 2021 via https://cdn.ampproject.org/v0/validator.20211101.deprecated.js. Ideally they would upgrade to https://cdn.ampproject.org/v0/validator_wasm.js or utilize an existing developer tool such as the Node.js Package.
Additional Context
Example of messaging returned by the deprecated native JavaScript validator via Node.js Package:
$ amphtml-validator --validator.js minimum_valid_amp.html
minimum_valid_amp.html:1:0 The native JavaScript AMPHTML Validator (validator.js) has been turned down. If you are seeing this error, update your tooling to instead load the API compatible WebAssembly AMPHTML Validator (validator_wasm.js) instead.
Example of messaging returned by the deprecated native JavaScript validator via DevTools:
> amp.validator.validateString('test');
validator.js:7 ERROR: The native JavaScript AMPHTML Validator (validator.js) has been turned down. If you are seeing this error, update your tooling to instead load the API compatible WebAssembly AMPHTML Validator (validator_wasm.js) instead.
Notifications
/cc @ampproject/wg-approvers