Giter Site home page Giter Site logo

apartment's Introduction

apartment

remove undesirable properties from a piece of css

motivation

tools like penthouse don't really care about specific properties, but if you have critical content with css rules such as animation or transition, you might end up with a lot more css than what you actually need to inline in your pages.

you can also use apartment to remove rules matching a selector string.

install

npm install apartment --save

examples

using the api:

apartment('.foo{font-size:12px;font-weight:bold}', { properties: ['font-size'] })
// <- '.foo{font-weight:bold}'
apartment('.foo{font-size:12px;}', { properties: ['font-size'] })
// <- ''
apartment('.foo{font-size:12px;font-weight:bold}', { selectors: ['.foo'] })
// <- ''

using the cli:

$ echo '.foo{font-size:12px;font-weight:bold}' | apartment -p font-size
> .foo{font-weight:bold}
$ echo '.foo{font-size:12px;}' | apartment -p font-size
>
$ echo '.foo{font-size:12px;}' | apartment -s .bar
> .foo{font-size:12px}

testing

npm test

license

mit

apartment's People

Contributors

bevacqua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

modulexcite jchip

apartment's Issues

Throws on multiple matched selectors

Unfortunately apartment throws on certain css, breaking latest version of Penthouse :/

Minimal test case:

apartment(`
::-moz-selection {
  color: #fff;
}
::selection {
  color: #fff;
}`, {
  selectors: [
    '::(-moz-)?selection'
  ]
}

The thrown error

/Users/jso/penthouse/node_modules/apartment/src/apartment.js:32
    if (inspected.type === 'rule') {
                 ^

TypeError: Cannot read property 'type' of undefined

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.