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

postcss-lang-optimizer

v1.3.2

Published

Extract language specific selectors to their own css file.

Downloads

8

Readme

PostCSS Lang Optimizer

Extract rulesets that are language specific into their own file so they can be served at runtime in a more optimal way.

The AST is walked only once and language specific rulesets are collected along the way. After processing, the language specific selectors can be written out to their own files or re-combined in various ways according to how you desire to send the locale specific CSS over the wire.

If a single selector has more than one lang or is combined with non-lang-specific selectors, then the ruleset is duplicated and the language specific selectors are removed.

API

langOptimizer = require("postcss-lang-optimizer");
postcss = require("postcss");

var optimizerOptions = {};
var input = ".foo { font-size: 14px; } .foo:lang(zh) { font-size: 18px; }"
var result = postcss(langOptimizer(optimizerOptions)).process(input);
// language agnostic CSS stripped of all language specific rulesets
result.css; // => ".foo { font-size: 14px; }"
// zh-specific CSS
langOptimizer.extract(result, "zh"); // => " .foo:lang(zh) { font-size: 18px; }"

Control Comments

You can disable and re-enable the language optimizer for portions of the CSS file by using control comments. When these comments are encountered, it will change the enabled state of the optimizer until the end of the file or until another control comment is encountered.

/* lang-optimizer: disable */
/* lang-optimizer: enable */

Options:

  • subtags - When set to true, then any language selectors will be extracted to their own file. That is de, de-DE and de-DE-1996 would each be extracted to their own file.

The following :lang features are not well supported:

  • Wildcard language matching E.g. :lang(*-CH) - These will be left in the base file.

Known Issues:

  • Sourcemaps will not work with language specific output files.

Ember Addon

There is an ember addon for this plugin. You can find it in the ember-addon branch.