npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mugiwara

v0.1.4

Published

blazing fast minimal css-in-js solution

Downloads

11

Readme

Mugiwara is a fast minimal CSS-in-JS created to reduce size of CSS injected

Mugiwara uses similar Virtual CSS concept to reduce bundle however using a preemption algorithm behind, called as Chain CSS.

CircleCI branch NPM Version

Status: Under development. Don't use it in Production.

Benchmark

cxs x 31,955 ops/sec ±5.10% (85 runs sampled)
fela x 29,790 ops/sec ±0.93% (85 runs sampled)
mugiwara x 33,806 ops/sec ±0.96% (86 runs sampled)
glamor x 25,009 ops/sec ±1.34% (85 runs sampled)
Fastest is mugiwara
✨  Done in 27.38s.

Principles:

  • Transform declarations in Shallow way

Browsers read selectors from right to left. The deeper the selectors are, the longer it takes for the browser to render and re-render the elements those selectors are applied to. For complex DOMs that reflow often, short selectors can also cut down on jank.

Good to read: Efficiently Rendering CSS

  • Prehemption

Feature not available yet, soon more details.

  • Remove redundances

Good to read: Remove Unused CSS to Reduce the Size of your Stylesheets

How Chain CSS works?

Algorithm still in development, here's a preview of first step:


Element A -> {color: 'blue', padding: '10px', fontFamily: 'Helvetica'}
Element B -> {color: 'red', borderRight: '1px solid #333'}
Element C -> {padding: 10, fontFamily: 'Helvetica'}

Result:

.A { 
  color: blue 
}
.A, .C { 
  padding: '10px', 
  fontFamily: 'Helvetica' 
}
.B { 
  border-right: '1px solid #333' 
}

Installing

yarn add mugiwara

Using it

Example with ReactJS:

import React from 'react'
import { render } from 'react-dom'
import { createClass, createStyles } from 'mugiwara'

const className = createClass({
  padding: 32,
  backgroundColor: 'green'
})

const Box = (props) => <div {...props} className={className} />

createStyles()

render(Box, document.querySelector('#root'))

Also valid API (still in draft):

const className = createClass(`
  position: 'abolute',
  padding: 32px,
  backgroundColor: 'green'

  & div {
    width: 100px;
  }
`)

Example with ReactJS Server side-render:

import React from 'react'
import ReactDOMServer from 'react-dom/server'
import { shallowStyles } from 'mugiwara'
import App from './App'

const renderedApp = ReactDOMServer.renderToString(<App />)
const staticPage = `
<html>
  <style>${shallowStyles()}</style>
  ${renderedApp}
</html>
`

console.log(staticPage)
/*
<html>
  <style>.app{position:absolute;display:flex;margin:0 auto;}.heading{font-family:Helvetica, arial;}</style>
  <div class="app" data-reactroot=""><div class="heading">MyApp</div></div>
</html>
*/

1.x ROADMAP

  • [ ] Support pseudo-selectors
  • [ ] Support to prefix
  • [ ] Check similar properties (e.g: #FFF, white) and keep one
  • [ ] Support MediaQueries
  • [x] Support Server Side Renderer
  • [ ] Cache features
  • [ ] Support React Native Style (using native-css)

Reference

  • https://www.creativebloq.com/how-to/5-tips-for-super-fast-css
  • https://ryantsao.com/blog/virtual-css-with-styletron