Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@ampproject/toolbox-runtime-version
Advanced tools
Use it to query cdn.ampproject.org
for the current release or canary version of the AMP Runtime. Uses a stale-while-revalidate caching strategy to avoid network requests in the critical path.
You can use the API to re-write AMP runtime URLs to their versioned counter parts to improve browser caching, e.g. to replace:
https://cdn.ampproject.org/v0.css
with:
https://cdn.ampproject.org/rtv/001515617716922/v0.css
Install via:
npm install @ampproject/toolbox-runtime-version
Basic usage:
const runtimeVersion = require('@ampproject/toolbox-runtime-version');
// Release version
runtimeVersion.currentVersion().then(version => {
console.log(version);
});
// Canary version
runtimeVersion.currentVersion({canary: true}).then(version => {
console.log(version);
});
// Rewriting cache URLs
const ampRuntimeUrl = 'https://cdn.ampproject.org/v0.js';
const version = await runtimeVersion.currentVersion();
const versionedAmpRuntimeUrl = ampRuntimeUrl.replace(
'https://cdn.ampproject.org/',
'https://cdn.ampproject.org/rtv/' + version + '/'
);
console.log(versionedAmpRuntimeUrl);
2.0.0
Migration notes:
The SeparateKeyframe
transformer's compress
option has been renamed to minify
. The same option will also be used by the MinifyHtml
transformer. The default value continues to be true
.
The API for implementing a custom transformer has changed. We no longer monkey patch the node class, but instead rely on helper methods defined in NodeUtils
:
const {firstChildByTag, appendChild, createElement} =
require('@ampproject/toolbox-optimizer').NodeUtils; class CustomTransformer { constructor(config)
{ this.log_ = config.log.tag('CUSTOM'); } transform(tree, params) { this.log_.info('Running custom
transformation for ', params.filePath); const html = firstChildByTag(tree, 'html'); if (!html)
return; const head = firstChildByTag(html, 'head'); if (!head) return; const desc =
createElement('meta', { name: 'description', content: 'this is just a demo', }); appendChild(head,
desc); } }
core
, optimizer
cli
, optimizer
optimizer
cors
optimizer
cli
, core
, cors
, optimizer
, update-cache
linter
, optimizer-express
cache-list
, cache-url
, cli
, core
, cors
, lighthouse-plugin-amp
, linter
, optimizer-express
, optimizer
, runtime-version
, script-csp
, update-cache
, validator-rules
FAQs
AMP Runtime versions
The npm package @ampproject/toolbox-runtime-version receives a total of 26,954 weekly downloads. As such, @ampproject/toolbox-runtime-version popularity was classified as popular.
We found that @ampproject/toolbox-runtime-version demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.