uncss | Remove unused styles from CSS | Style Language library
kandi X-RAY | uncss Summary
kandi X-RAY | uncss Summary
UnCSS is a tool that removes unused CSS from your stylesheets. It works across multiple files and supports Javascript-injected CSS.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- This function is used to find unused rules .
- Initialize the package .
- Processes the text from a CSS API
- Fetch relative paths
- Read stylesheets from files
- Parse CSS message .
- Get CSS from files
- Filter ignore selector
- Find all selected scripts .
- Create a JSDoc from a given source .
uncss Key Features
uncss Examples and Code Snippets
var Metalsmith = require('metalsmith');
var uncss = require('metalsmith-uncss');
Metalsmith(__dirname)
.source('./src')
.destination('./dest')
.use(uncss({
css: ['bootstrap.css','app.css'], // CSS files to run through UnCSS
html: ['index.html
$yarn add --dev cssnano
$yarn add --dev uncss
npm install --save metalsmith-uncss
var uncss = require('metalsmith-uncss');
const gulp = require("gulp"),
appRoot = require("app-root-path"),
sass = require("gulp-sass"),
path = require("path"),
utilities = require(appRoot + "/Tools/Utilities-Functions/utilities-functions.js"),
fs = require("fs
const uncss = require('postcss-uncss');
mix.js('js/dev/app.js', 'js/build/app.js')
.sass('css/dev/app.scss', 'css/build')
.options({
processCssUrls: false,
postCss: [
tailwindcss('./tailwind.config.js')
ignore (Array): provide a list of selectors that should not be removed by UnCSS. For example, styles added by user interaction with the page (hover, click), since those are not detectable by UnCSS yet. Both literal names and regex patterns
Community Discussions
Trending Discussions on uncss
QUESTION
I'm using Grunt to remove unused CSS on my page. Everything works pretty good, but unfortunately sometimes a few code snippets get removed, although being crucial for the website.
I would like Grunt to ignore all @media (min-width: ...)
CSS Rules,
but I don't know how to phrase that in my Gruntfile.JS
.
For Example:
styles.css
...ANSWER
Answered 2019-Sep-11 at 15:56Add the comment: /* uncss:ignore start */
to the line preceding your @media ...
query in the styles.css file, and also add the closing comment /* uncss:ignore end */
to the next line following the end of the @media
query.
Any rule(s) between those two comments will be ignored.
Example of styles.css:
QUESTION
I'm using PostCSS and I want to add Post-uncss. I use no task runners, just Postcss-cli. My package.json looks like this right now:
...ANSWER
Answered 2018-Nov-29 at 01:59You can pass plugin parameters within a postcss.config.js
file like so:
QUESTION
I am trying to deploy a Foundation web app based on Yarn, Gulp and Node.js on Heroku. It works with heroku local web
but crashes on the Heroku server.
I have set the port correctly. I am trying to remove Browsersync and use gulp-connect instead. In my gulpfile.js
I have set the connectHeroku
task which is run after build. I have set the yarn start
command in the environment for Heroku.
Here is my gulp.babel.js
:
ANSWER
Answered 2019-Jul-10 at 18:18OK so here is what I've managed to do and it worked (pls note that I am very new to this): Stack: Zurb Foundation template (zurb foundation) which uses yarn and gulp for packet management and build. Outputs to a folder called dist (changeable in the config.yml); Expressjs; NodeJS.
QUESTION
I am trying to remove unused css rules from one or more of my sass files.
Research led me to postcss-uncss as the best option for removing unused css if you do not use server-side rendering (see: https://www.purgecss.com/comparison)
https://github.com/uncss/postcss-uncss
Now, postcss-uncss is a wrapper for uncss: https://github.com/uncss/uncss However, the uncss documentation is confusing to me, and the example configuration here is not useful: https://github.com/uncss/postcss-uncss#example-configuration
How does one configure postcss-uncss for Laravel Mix?
THis is what I have so far:
...ANSWER
Answered 2019-Jul-02 at 06:47Perhaps you might try the Spatie package?
Let's install it.
QUESTION
I get the following error. I've tried to force the installing of the canvas package but with no luck. Does the following error mean that I have to find a way to install the dependency of uncss?
...ANSWER
Answered 2019-Jan-25 at 01:49This is an open issue still for uncss (Issue) , but for other packages that use canvas it seems this could be sorted out by using
QUESTION
With uncss we can remove unused css from our stylesheets. It works by looking at the html files to be deployed and only packaging the css rules used.
Angular 4 has directives that apply conditional css like this:
...ANSWER
Answered 2017-May-19 at 05:31I am building a tool that can that. It is still in beta though but would love to try it against your app. The tool uses a snippet of JavaScript to detect the CSS selectors being used. Every time a user is interacting with the page, it triggers a new cycle of test.
A server aggregates the results. Finally, the tool can trigger pull-request against your code to actually remove the unused CSS once it evaluate that a selector can be safely removed, aka not being used in X days.
If you want to try it, go to https://www.bleachcss.com
QUESTION
I have a CSS file that I need to optimize for loading. It's big with many different components that are used on many different pages (start page, category pages, detail pages) on different breakpoints (mobile, table, desktop), thus manual optimization is complicated. At least extracting the most important parts would help load times (as it's blocking rendering) - the current big file can be loaded async.
What I've tried is using the various critical css extractors and uncss. But all of them can only extract the CSS for one page in one breakpoint.
Is there any tool that I've missed? I'm looking for something that can do
magic-used-css-extractor 400px,1024px,2048px http://example.com/ http://example.com/category1/ http://example.com/category2/ http://example.com/detail1/ http://example.com/detail2/
and returns a CSS that matches the used CSS on all of these pages. Or a tool that can merge a couple of critical CSS in correct order with at-rules.
...ANSWER
Answered 2018-May-18 at 09:30Just yesterday I've seen a trick done by https://github.com/addyosmani/critical
It supports multiple dimensions, but not multiple pages. Still the same trick might be applied to merge the critical css after running it on a couple of important pages.
The tool critical is using is https://github.com/jakubpawlowicz/clean-css, which would remove duplicate rules and therefor merge multiple css files.
See here for reference: https://github.com/addyosmani/critical/blob/master/lib/core.js#L30
QUESTION
Here is to minify html file inside gulp as follow
...ANSWER
Answered 2018-May-14 at 04:52Which plugin are you using? Gulp-minify-html? That is deprecated. If you are using that try the option "comments: true" as in :
QUESTION
How would you show the results from multiple selected options using amp-selector
?
For example in the code below,
If you select both US & Europe, the list should show:
- US
- US
- US & Europe
- Europe
- Europe
- Australia & US & Europe
ANSWER
Answered 2018-Mar-08 at 06:18As I know amp-selector just allow single select. I think in this case try using checkbox
QUESTION
I am losing my mind with javascript in Foundation 6.4. I have no idea what's going on with this Webpack thing. It seems like some libraries/plugins work and some do not. My latest issue is with plyr (https://plyr.io/). I do not understand why TweenMax works 100% fine and plyr.js does not. What am I doing wrong?
This is the error I get..
app.js:23026 Uncaught ReferenceError: plyr is not defined
This is what my app.js
looks like..
ANSWER
Answered 2018-Feb-04 at 05:26You might need to use something like expose-loader so that plyr
is available globally on window
. Here's more info on how we used expose-loader in our project.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install uncss
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page