UnCSS your CSS! Removing Unused CSS with PostCSS & Parcel

  Рет қаралды 59,558

DesignCourse

DesignCourse

Күн бұрын

promo.linode.com/designcourse/ - Use code 'DESIGNC19' to get $20 credit on your new Linode account!
-- Last week I released a video discussing Bootstrap. In this video, I mentioned I used PurgeCSS to remove unwanted CSS, which resulted in a drastically smaller file size. Today, we're going to use a similar tool called UnCSS with the help of PostCSS to do just that.
PostCSS allows you to chain together a number of CSS tools.
You can use PostCSS in a number of environments, and for this one, we're going to use Parcel (You can also use Gulp, Grunt, Webpack, etc..).
Uncss comes with a plugin that allows it to work with PostCSS, which is what we'll use. Uncss simply compares your HTML against your CSS, and removes any unused CSS rulesets.
Project files:
coursetro.s3.amazonaws.com/st...
Let's get started!
- - - - - - - - - - - - - - - - - - - - - -
Subscribe for NEW VIDEOS!
My site: designcourse.com
My personal FB account: logodesigner
Coursetro FB: coursetro
Coursetro's Twitter: / designcoursecom
Join my Discord! / discord
^-Chat with me and others
- - - - - - - - - - - - - - - - - - - - - -
Who is Gary Simon? Well, I'm a full stack developer with 2+ decades experience and I teach people how to design and code. I've created around 100+ courses for big brands like LinkedIn, Lynda.com, Pluralsight and Envato Network.
Now, I focus all of my time and energy on this channel and my website Coursetro.com.
Come to my discord server or add me on social media and say Hi!

Пікірлер: 74
@DesignCourse
@DesignCourse 4 жыл бұрын
Sub up if you enjoy, as always!
@justingolden21
@justingolden21 3 жыл бұрын
I thought this said "shutup if you enjoy" and I was like wut lmao
@_the_one_1
@_the_one_1 4 жыл бұрын
as always great video! Thanks for sharing
@Github_tech_with_ty
@Github_tech_with_ty 4 жыл бұрын
Yes was looking for this
@dannyspivak6526
@dannyspivak6526 4 жыл бұрын
Thank you for the video, good one
@abhishreymittal
@abhishreymittal 4 жыл бұрын
I might use it in the future, but still, it is always a pleasure to watch your videos... BTW when is the next NegativeSpace coming?
@DesignCourse
@DesignCourse 4 жыл бұрын
Maybe this Friday.
@davidetiosaojo8258
@davidetiosaojo8258 4 жыл бұрын
Hey Gary, love your videos!! I've been following you channel for a while now and it has been awesome... But I'm having issues with this tutorial though; I can't quite install the "parcel-bundler" I keep getting an error when I run the "npm i parcel-bundler".. Any solutions??!
@Grewal0007
@Grewal0007 4 жыл бұрын
Thank you so much Sir
@Sam-rd5bo
@Sam-rd5bo 2 жыл бұрын
Is there a chance it can remove CSS that maybe getting used on other pages or only getting used if certain action happens? Or perhaps CSS that gets applied as new elements are created. I wonder how safe it is to use unCSS?
@ZeR0ByTe
@ZeR0ByTe 4 жыл бұрын
Great!! thanks!!!
@_the_one_1
@_the_one_1 4 жыл бұрын
Hey Gary I am learning testing vue.js applications and did that but buying a book. Though there is not useful resources out there, I mean there are not quality videos to show you how to test vue.js applications and most of developers prefer to learn by wathing videos. Is it in your plans to create a play list "Testing vue applications with jest" ?
@oussamasethoum2755
@oussamasethoum2755 4 жыл бұрын
Thanks.
@akash-kumar737
@akash-kumar737 4 жыл бұрын
You are awesome.
@Github_tech_with_ty
@Github_tech_with_ty 4 жыл бұрын
Thank you good sir
@bjartur96
@bjartur96 4 жыл бұрын
Does this also work if you are adding classes afterwards with JS?
@hayleykornilenko6314
@hayleykornilenko6314 4 жыл бұрын
Does this work across the entire site or just the page it is rendering for the Coverage feature?
@TM-vg2mt
@TM-vg2mt 4 жыл бұрын
Can you suggest me, what best framework to make a dynamic web company profiles?
4 жыл бұрын
Thanks for the video, changing the theme, can I apply uncss with an Angular project?
@AymanAlSagher
@AymanAlSagher 4 жыл бұрын
I have the same question! 😁
@SummerSC2
@SummerSC2 4 жыл бұрын
Yes plz I want to know that as well
@sumanchatterjee2336
@sumanchatterjee2336 3 жыл бұрын
sir if i have multiple pages, each page using different css properties from my common css file(like one page using 3-4 animations and other page didn't using them), then how should i do uncss of the css which are not common for each page ?
@ramyalayan9121
@ramyalayan9121 4 жыл бұрын
Can you please do this with Webpack and share it with us? I've been trying to do it with Webpack for 2 hours and still no luck :/
@RockuMan
@RockuMan 4 жыл бұрын
On the paper, uncss is a great idea, but for real world production products is more of a hassle than a practical tool: a lot of styles can’t be understood by the various uncss plugins, such as pseudo elements, dynamically injected classes etc. As the project grows, keeping track of everything uncss should “ignore” can become time consuming.
@harryadneyinternetservices
@harryadneyinternetservices 4 жыл бұрын
Nice one mate. As it happens, I had just experimented with Parcel for the first time acoup[le of minutes before watching this video, so a nice bit of serendipity, there.
@pamelahicks
@pamelahicks 4 жыл бұрын
One reason there could still be some unused css remaining is because of reset styles. For example, button { color: inherit; } would still be in your css even if every button used had a class like .btn { color: blue; } because the package found button elements and wouldn’t delete their css.
@pamelahicks
@pamelahicks 4 жыл бұрын
Nixon Kosgei presumably it wouldn’t be code you wrote yourself; in this vid the example was Bootstrap, and as far as I know, Bootstrap uses some kind of reset that would target some elements (don’t quote me on that one) like inputs and whatnot.
@pamelahicks
@pamelahicks 4 жыл бұрын
Nixon Kosgei yes and it’s not a bad thing! Just an observation I made on one of my own projects using PurgeCSS. In my example above, the button reset style for color: inherit isn’t really needed anymore but wouldn’t be removed.
@amarg26
@amarg26 3 жыл бұрын
Is it possible to remove unused Js from core files like jquery,jquery-ui and bootstrap.js? if yes how to do it? Wiil be great if we have new video on this. Thanks a lot.
@user-nx6un5ur4w
@user-nx6un5ur4w 4 жыл бұрын
Hello! Please tell me how to do the same only on the gulp? gulp + postssss + unkss
@e11world
@e11world 3 жыл бұрын
Would love to see how you can use purgecss with gulp (using it now but having a hard time adding this or unusedcss to my gulp file since I'm using var paths for css/html and so on)
@vasiovasio
@vasiovasio 3 жыл бұрын
I can recommend you to try cssnano too, it is Amazing tool!
@morespinach9832
@morespinach9832 2 жыл бұрын
How about if I have 7-8 page template types in my website. Wordpress. Using uikit framework. Can i point purgecss or postcss or uncss with that?
@yassinesafraoui4540
@yassinesafraoui4540 4 жыл бұрын
is sass using uncss, if not is there is any way to make it support it?
@danielbaychev9297
@danielbaychev9297 3 жыл бұрын
For anyone having the restricted policy error, Run this: Set-ExecutionPolicy RemoteSigned
@kenny1394
@kenny1394 4 жыл бұрын
How do you save your own website's html file and css file??
@RizaHariati
@RizaHariati 2 жыл бұрын
I can't use it using React.js. I don't know where to put the file. The index.html is in the public folder. And the parcel just won't work.
@Dopefish1337
@Dopefish1337 5 ай бұрын
Hello, my homepage has an index.php file instead of .html, is this still possible?
@TutoDS2014
@TutoDS2014 4 жыл бұрын
Works in Laravel project
@apafly
@apafly 4 жыл бұрын
I'm trying this from a Mac with this error and no wat to fix it: "Please specify a publicURL using --public-url, otherwise schema assets won't be collected" I've tried --public-url '.' --public-url index.html --public-url ./ --public-url / but didn't work
@sherifsalah5563
@sherifsalah5563 4 жыл бұрын
Does it keep js added classes? Because i tried purgecss with parcel before and it removed all js added classes! I just checked and it doesn't .. so its not useful at all unless you are creating one dummy page.
@krubex
@krubex 4 жыл бұрын
that's what I asked myself, too. If that's really the case, it isn't that useful. Shouldn't it be possible to scan not just html files, but also js files to look for classes/id's/elements?
@vikrantmagare3836
@vikrantmagare3836 2 жыл бұрын
Can we do this for js also
@fzmhd3324
@fzmhd3324 3 жыл бұрын
sir how to configure this for multiple page website please give me a replay sir
@thebetacoders4738
@thebetacoders4738 3 жыл бұрын
Can you please make a tutorial kn how to remove unused Css in Angular 11????????
@bionicbrainbutt
@bionicbrainbutt 3 жыл бұрын
No record feature on my dev panel
@alexandertorres8854
@alexandertorres8854 4 жыл бұрын
Curious if this can be done in Angular with Angular CLI?
@DesignCourse
@DesignCourse 4 жыл бұрын
I haven't tried. Angular uses webpack though, and PostCSS can work with webpack. I'm not sure how straight forward that would be.
@alexandertorres8854
@alexandertorres8854 4 жыл бұрын
@@DesignCourse would be great to see a video on using it with Angular.
@srikanthchilakabathula194
@srikanthchilakabathula194 4 жыл бұрын
Grate video..your videos are soo good to watch.. *Please tell how to remove unused js*
@graphicclub868
@graphicclub868 4 жыл бұрын
wao isee your this logo design video
@andrewkiminhwan
@andrewkiminhwan 4 жыл бұрын
has anyone tried this for django project?
@ruhankhandakar
@ruhankhandakar 4 жыл бұрын
do we have any unjs ???
@TheRonoxcz
@TheRonoxcz 4 жыл бұрын
Im wondering the same.
@MatthewChenIsAwesome
@MatthewChenIsAwesome 4 жыл бұрын
Parcel comes with tree-shaking, which eliminates JS dead code
@DavidElstob73
@DavidElstob73 4 жыл бұрын
If you can do the same job with PurgeCSS then why make it more complex using PostCSS and UnCSS?
@DesignCourse
@DesignCourse 4 жыл бұрын
I personally like using Parcel instead of something like Gulp. So, Parcel works well with PostCSS. If you want to use PurgeCSS with Gulp or something, their docs are straight forward.
@DavidElstob73
@DavidElstob73 4 жыл бұрын
@@DesignCourse yeah I guess most things are personal preference.
@MrLutor
@MrLutor 3 жыл бұрын
How to deal with nuxt??? help pls anybody)
@viktoralferov2874
@viktoralferov2874 4 жыл бұрын
Compressed bottstrap is 20KB, 140 KB - is uncompress
@amiraziz7531
@amiraziz7531 4 жыл бұрын
Need Html Css project building
@gilbster
@gilbster 4 жыл бұрын
Isn't 150kb tiny?
@MatthewChenIsAwesome
@MatthewChenIsAwesome 4 жыл бұрын
not on the web, esp. with weaker android devices on poor 3rd world connections
@JamesWelbes
@JamesWelbes 4 жыл бұрын
That was very complicated
@lucadonno4489
@lucadonno4489 4 жыл бұрын
James Welbes yea too complicated
@JamesWelbes
@JamesWelbes 4 жыл бұрын
@@lucadonno4489 you can just paste your HTML and CSS here: and it will output your "lean" CSS purifycss.online/
@JamesWelbes
@JamesWelbes 4 жыл бұрын
@@lucadonno4489 also here's this guy's Parcel tutorial: kzfaq.info/get/bejne/hbFmlM54v6mnaGw.html
@MyALPHAguy
@MyALPHAguy 4 жыл бұрын
Didn't work the way it should lol
@waleedkh9769
@waleedkh9769 4 жыл бұрын
I think this is useless.
Learn how to power-up your CSS with PostCSS
20:23
Kevin Powell
Рет қаралды 81 М.
You Probably Need BEM CSS in Your Life (Tutorial)
18:47
DesignCourse
Рет қаралды 163 М.
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 94 МЛН
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 14 МЛН
Customise Bootstrap's Sass
22:27
Pixel Rocket
Рет қаралды 12 М.
How To Optimize Font Awesome For Unused CSS
6:46
The Website Architect
Рет қаралды 6 М.
Learn PostCSS In 15 Minutes
14:39
Web Dev Simplified
Рет қаралды 90 М.
Every modern site should be using PostCSS!
18:58
Coding in Public
Рет қаралды 14 М.
Remove unused Angular Material CSS (2020)
9:48
Decoded Frontend
Рет қаралды 10 М.
The ultimate guide to web performance
6:43
Beyond Fireship
Рет қаралды 411 М.
The secret to mastering CSS layouts
17:11
Kevin Powell
Рет қаралды 269 М.
Look at two different videos 😁 @karina-kola
0:12
Andrey Grechka
Рет қаралды 7 МЛН
Cat Tommy lost his love…💔 #cat #cats
0:27
Prince Tom
Рет қаралды 133 МЛН
love jesus❤️🥰❤️‍🩹🙏#jesus #love #shorts
0:18
jesus win devil999+
Рет қаралды 27 МЛН
POR QUEEEE DIVERTIDAMENTE 2 😭 #shorts
0:15
Figuritalo
Рет қаралды 6 МЛН
Smart Appliances! New Gadgets, Versatile Utensils, Tool Items #shorts #gadgets 149
0:15
Решила папу порадовать
0:33
FanClub Garik Ugarik
Рет қаралды 2,5 МЛН