Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amp-custom

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amp-custom

Optimize CSS source for AMP HTML.

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-93.55%
Maintainers
1
Weekly downloads
 
Created
Source

amp-custom

License: MIT npm version Build Status Coverage Status

Optimize CSS source for AMP HTML.

If you are using PostCSS, use postcss-amp-custom.

CLI

Run amp-custom by CLI.

npx amp-custom input.css output.css

API

Install package.

npm install --save-dev amp-custom

Run amp-custom by API.

const AmpCustom = require('amp-custom')
const ampCustom = new AmpCustom()
const cssSource = `@charset "UTF-8";
body {
  font-size: 16px;
}
@page hoge {
  size: portrait;
  margin: 15mm;
}
a {
  color: #39c !important;
  text-decoration: none;
}
@viewport {
  min-width: 640px;
  max-width: 800px;
}
@supports not (display: flex) {
  .flexbox {
    overflow: hidden;
  }
  .flexbox div {
    float: left;
  }
}`

ampCustom.optimize(cssSource) // 'body{font-size:16px}a{color:#39c;text-decoration:none}'

optimize(cssSource: String): String

Optimize CSS for AMP.

const cssSource = `@charset "UTF-8";
body {
  font-size: 16px;
}
@page hoge {
  size: portrait;
  margin: 15mm;
}
a {
  color: #39c !important;
  text-decoration: none;
}
@viewport {
  min-width: 640px;
  max-width: 800px;
}
@supports not (display: flex) {
  .flexbox {
    overflow: hidden;
  }
  .flexbox div {
    float: left;
  }
}`

ampCustom.optimize(cssSource) // 'body{font-size:16px}a{color:#39c;text-decoration:none}'

isOverMaxByte(cssSource: String): Boolean

Check the CSS string size meets the AMP rules (75KB).

const cssSource = 'body{font-size:16px}a{color:#39c;text-decoration:none}'

ampCustom.isOverMaxByte(cssSource) // false

License

MIT License.

Keywords

FAQs

Package last updated on 26 Dec 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc