Don't relyonoptimizationtoolstomakeyou a goodCSSthreecoder.
As I alwaysliketosaycrapincrapout, Thatsimplymeansifyouareputtingsomethingterribleintothemachine, somethingterriblewillcomeoutnomatterhowmuchyouprettifyoroptimizeorcompressthedarnedthing.
Ifyou'redoing a badjobin, it's gonnabe a baddrugcomingout.
Andthatsimplymeansifyoucanselectsimplytheideaofawesomedon't selectDivparagraphtagspan m ideaofawesome.
Justsimplyusingtheideaofawesomeisgoodenough.
ThatinandofitselfissmartCSSthreecoating.
Utilizegoodcodeorganization.
Soinsteadofwhenyouhaveanideafor a stylejustthrowingitatthebottomofyourCSSstylesheet, findoutwhere a goodplaceforthatpieceofcodeis, and a nicelittletipis.
Put a tableofcontentsin a commentabouttheverytopofyourstylesheet.
Ifyouhave a reallybigandheavyCSSstylesheet, havesomeorganizationandhave a waythatyouinthefuturecanrevisityourcode.
Ifyouhave a productionreadystylesheetthatyouwannahavereadytogo, thenyoucanhaveitatitshighestcompressionbecauseyoudon't needtobeabletoreaditandmodifyit.
Youdon't actuallyhavetohave a semicolononyourlaststyle.
So, forexample, hereinthisentireselectorfinalshadowtypeofrighthere, thisonedoesn't actuallyneed a semicolon.
But I alwaysdoitbydefaultbecause I don't wanttogetintothehabitwhen I'm writingvanillaCSStoforgetthesemicolon, butinyourproductionreadysightandyou'recompressingyourcode, youcanhaveatit.
Youcandiscardinvalidpropertiesandat a timestampforwhenitwasoptimizeduptoyou, processthatCSSletsyouknowwhatwhenwhatwenton.
Youcanyoucando a tonwithit, butin a verybasicway, youcanoptimizeyourCSSandevencompressimagesanddoeverythinglikethatandhaveitautomaticallyoutputinto a folderthatyouwant.
So, forexample, I have a folderherecalledthemestylesonthen a coupleCSSfileshere.
I canactuallysayoutputstylecompressed.
Theycanchoosehow I wantittobecompressed, and I canchangethepath.
Soletmesay I'm gonnacreate a newfoldercalledProductionlikewejusttalkedabout, andit's goingtosaythemeinproductionon C.
S s youcancallwhateveryouwant, but I'm gonnasaythisisgonnatakethatfileandit's goingtoturnitintosomething.
I wanttohitprocess.
Boom!
It's goingtodothatCompiled.
Soinherenowwehave a productionfilecalledThemeinProduction.
CSS.
Let's checkitout.
Soit's gotalloftheCSSthatwasintheoriginaltheme.
CSS.
Soallofthisisnowcompressed.
But I'm notoverwritingthis.
It's justgotanotherfilenow.
Themagicofthisis I canhaveitrunautomaticallywhenthisfilechangesairbuild.
Soit's checkingthisfilewhenitchangesreoutput.
Soas a littleexample, if I justdeleteeverythingandjust a bodyfontsize 12 pixelsandleaveitatthatandsave, it's goingtoreoutput, itjustprocessedit.
Andnowthatfileisthatsoitautomaticallyhappens.
Youdon't needtoresavecopyandpaste.
Takeitdowntothis.
Thatandalltheotherthings.
And I'm justgonnachangethatbackbecausethatwas a veryimportantfile.
So I'm gonnagobackhitsave.
It's goingtocompileBam!
Everythingisback.
Therewego.
So I wouldhighlysuggestusingcodekitforthoseproductionforgivingandthekneadingproductionreadyfiles.
Youcanoptimize a tonofstuff, butbecausethisisCSS, we'rejustgonnatalkaboutthat.
TheotherthingthatyoucandoispreloadyourCSSinthebrowsersoyoucanimprovetheperformanceandtheloadingtimeofyourstylesonyourWebsitesbysimplyaddingthefollowingcodelinkpreload a tripandwhateveryourCSSisasstyle.
Soyou'rebasicallyusingtherelatributetotellthebrowsertopreloadthisfileas a style, anditwilljustcheck a littlebitearlierandloadthatstyleit.
Sothere's lesswaitingtime.
Otherthingyoucoulddoislightenupthoseframework.
Sobootstrapandothersimilarframer, sir, notoriouslyheavy, meaningthatthereare a lotoffiles, functions, assetsandcodethatyousimplydonotneedinthewebsite.
And I put a resourceintheinthefileandDaynumber 28 calledShorthandPropertiesteachesyou a littlebitaboutusingshorthandsand a littlebitof, ah, ofhowtoimproveyourCSScoding.
Sothanksforspending a little 15 minutesorso, learning a littlebitoftheoryandwhyyoushouldoptimizeyourCSSseeitsmoralondaynumber 29.