幽灵资源网 Design By www.bzswh.com
我们都熟知JavaScript可能会对Web页面的加载与显示产生较大的影响,因此我们常常关注JavaScript是不是会占用客户端较多的资源,然而大部分都会忽略的一件有趣的事情,CSS也会对Web页面载入的效率产生影响。
  我们罗列了十几条相关的知识与注意点,大家可以系统的探讨一下,让我们编写的Web页面打开更加流畅。
  请不要告诉我,你看不懂E文,只是你不愿意看!!!
  1、Howthestylesystembreaksuprules
  Thestylesystembreaksrulesupintofourprimarycategories.Itiscriticaltounderstandthesecategories,astheyarethefirstlineofdefenseasfarasrulematchingisconcerned.Iusethetermkeyselectorintheparagraphsthatfollow.Thekeyselectorisdefinedtobetherightmostoccurrenceofanidselector,aclassselector,oratagselector.
  1.1、IDRules
  ThefirstcategoryconsistsofthoserulesthathaveanIDselectorastheirkeyselector.
button#backButton{}/*ThisisanID-categorizedrule*/
#urlBar[type="autocomplete"]{}/*ThisisanID-categorizedrule*/
treeitem>treerow>treecell#myCell:active{}/*ThisisanID-categorizedrule*/
  1.2、ClassRules
Ifarulehasaclassspecifiedasitskeyselector,thenitfallsintothiscategory.
button.toolbarButton{}/*Aclass-basedrule*/
.fancyText{}/*Aclass-basedrule*/
menuitem>.menu-left[checked="true"]{}/*Aclass-basedrule*/
  1.3、TagRules
  IfnoclassorIDisspecifiedasthekeyselector,thenthenextpotentialcategoryforaruleisthetagcategory.Ifarulehasatagspecifiedasitskeyselector,thentherulefallsintothiscategory.
td{}/*Atag-basedrule*/
treeitem>treerow{}/*Atag-basedrule*/
input[type="checkbox"]{}/*Atag-basedrule*/
  1.4、UniversalRules
  Allotherrulesfallintothiscategory.
:table{}/*Auniversalrule*/
[hidden="true"]{}/*Auniversalrule*/
*{}/*Auniversalrule*/
tree>[collapsed="true"]{}/*Auniversalrule*/
  2、HowtheStyleSystemMatchesRules
  Thestylesystemmatchesarulebystartingwiththerightmostselectorandmovingtotheleftthroughtherule'sselectors.Aslongasyourlittlesubtreecontinuestocheckout,thestylesystemwillcontinuemovingtotheleftuntiliteithermatchestheruleorbailsoutbecauseofamismatch.
  Yourfirstlineofdefenseistherulefilteringthatoccursbasedonthetypeofthekeyselector.Thepurposeofthiscategorizationistofilteroutrulessothatyoudon'tevenhavetowastetimetryingtomatchthem.Thisisthekeytodramaticallyincreasingperformance.Thefewerrulesthatyouevenhavetocheckforagivenelement,thefasterstyleresolutionwillbe.Asanexample,ifyourelementhasanID,thenonlyIDrulesthatmatchyourelement'sIDwillbechecked.Onlyclassrulesforaclassfoundonyourelementwillbechecked.Onlytagrulesthatmatchyourtagwillbechecked.Universalruleswillalwaysbechecked.
  3、GuidelinesforEfficientCSS
  3.1、AvoidUniversalRules!
  Makesurearuledoesn'tendupintheuniversalcategory!
  3.2、Don'tqualifyID-categorizedruleswithtagnamesorclasses
  IfyouhaveastylerulethathasanIDselectorasitskeyselector,don'tbotheralsoaddingthetagnametotherule.IDsareunique,soyou'reslowingdownthematchingfornorealreason.
BAD-button#backButton{}
BAD-.menu-left#newMenuIcon{}
GOOD-#backButton{}
GOOD-#newMenuIcon{}
  3.3、Don'tqualifyclass-categorizedruleswithtagnames
  Similartotheruleabove,allofourclasseswillbeunique.Theconventionyoushoulduseistoincludethetagnameintheclassname.
BAD-treecell.indented{}
GOOD-.treecell-indented{}
  3.4、Trytoputrulesintothemostspecificcategoryyoucan!
  Thesinglebiggestcauseofslowdowninoursystemisthatwehavetoomanyrulesinthetagcategory.Byaddingclassestoourelements,wecanfurthersubdividetheserulesintoclasscategories,andthenwenolongerwastetimetryingtomatchasmanyrulesforagiventag.
BAD-treeitem[mailfolder="true"]>treerow>treecell{}
GOOD-.treecell-mailfolder{}
  3.5、Avoidthedescendantselector!
  ThedescendantselectoristhemostexpensiveselectorinCSS.Itisdreadfullyexpensive,especiallyifaruleusingtheselectorisinthetagoruniversalcategory.Frequentlywhatisreallydesiredisthechildselector.TheuseofthedescendantselectorisbannedinUICSSwithouttheexplicitapprovalofyourskin'smoduleowner.
BAD-treeheadtreerowtreecell{}
BETTER,BUTSTILLBAD(seenextguideline)-treehead>treerow>treecell{}
  3.6、Tag-categorizedrulesshouldnevercontainachildselector!
  Avoidusingthechildselectorwithtag-categorizedrules.Youwilldramaticallyincreasethematchingtime(especiallyiftheruleislikelytobematchedmoreoftenthannot)foralloccurrencesofthatelement.
BAD-treehead>treerow>treecell{}
BEST-.treecell-header{}
  3.7、Questionallusagesofthechildselector!
  Becarefulaboutusingthechildselector.Ifyoucancomeupwithawaytoavoidhavingtouseit,doso.Inparticular,thechildselectorisfrequentlyusedwithRDFtreesandmenuslikeso.
BAD-treeitem[IsImapServer="true"]>treerow>.tree-folderpane-icon{}
  RememberthatattributesfromRDFcanbeduplicatedinatemplate!TakeadvantageofthisfacttoduplicateRDFpropertiesonchildXULelementsthatwishtochangebasedoffthatattribute.
GOOD-.tree-folderpane-icon[IsImapServer="true"]{}
  3.8、Relyoninheritance!
  Learnwhichpropertiesinherit,andallowthemtodoso!WehaveexplicitlysetupXULwidgetrysothatyoucanputlist-style-image(justoneexample)orfontrulesontheparenttag,anditwillfilterintotheanonymouscontent.Youdon'thavetowastetimewritingarulethattalksdirectlytotheanonymouscontent.
BAD-#bookmarkMenuItem>.menu-left{list-style-image:url(blah);}
GOOD-#bookmarkMenuItem{list-style-image:url(blah);}
  Intheaboveexample,thedesiretostyletheanonymouscontent(withoutunderstandingthatlist-style-imageinherits)resultedinarulethatwasintheclasscategory,whenthisrulereallyshouldhaveendedupbeinginthemostspecificcategoryofall,theIDcategory.
  Remember,especiallywithanonymouscontent,thattheyallhavethesameclasses!Thebadruleabovecausestheiconofeverymenutobecheckedtoseeifitiscontainedinthebookmarksmenuitem.Thisishideouslyexpensive(sincetherearemanymenus);thisrulenevershouldhaveevenbeencheckedbyanymenuotherthanthebookmarksmenu.
  3.9、Use-moz-image-region!
  Puttingabunchofimagesintoasingleimagefileandselectingthemwith-moz-image-regionperformssignificantlybetterthanputtingeachimageintoitsownfile.
  OriginalDocumentInformation-Author:DavidHyatt
标签:
网页,教程,网页制作,注意,相关,编写,打开,流畅,知识,"

幽灵资源网 Design By www.bzswh.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
幽灵资源网 Design By www.bzswh.com

稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!

昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。

这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。

而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?