Isantya seSiza kunye neJavascript engavakaliyo

njenge-asynchronous

Ngelixa ndisenza inkqubela phambili, andizichazi njengomphuhlisi oyinyani. Ndiyakwazi ukwenza inkqubo kunye nokuhambisa izinto kwiphepha kwaye ndiyenze isebenze. Umphuhlisi oyinyani uyayiqonda indlela yokuphuhlisa ikhowudi ukuze ikalwe, ingathathi izinto ezininzi, zilayishe ngokukhawuleza, zilungiswe ngokulula kamva kwaye zisasebenza.

Indawo enzima abathengisi ababekwa kuyo bobabini banayo ngokukhawuleza okukhulu kwiwebhu kwaye usabandakanya ukudityaniswa kunye nezinto zentlalo ezinokudala ukuxhomekeka ekubeni indawo yakho izakulayisha ngokukhawuleza kangakanani. Omnye umzekelo ngu amaqhosha ezentlalo. KwiMartech, sinamaqhosha entlalontle kwiphepha ngalinye kwisiza. Ke… ukuba izixhobo ze-Facebook zilayishwa kancinci ngolunye usuku, iyacothisa indawo yethu. Emva koko yongeza i-Twitter, iPinterest, iBuffer, njl.nje kuloo ndawo kunye namathuba esiza sakho sokulayisha ngokukhawuleza ancitshisiwe angabinanto.

Oko kwaziwa njengokulayisha ngokuhambelana. Kuya kufuneka ugqibe ukulayisha into enye phambi kokuba ulayisha into elandelayo. Ukuba uyakwazi ukulayisha izinto ngokuzithandela, uyakwazi ukulayisha izinto ngaphandle kokuxhomekeka komnye nomnye. Ungasiphucula kakhulu isantya sendawo yakho ngokulayisha izinto ngokuzithandela. Ingxaki kukuba izikripthi ezingaphandle kwebhokisi ezibonelelwa zezi nkampani phantse azilungiswanga ukuba ziqhubeke njenge-asynchronous.
njenge-asynchronous

Uyayibona into echaphazela isantya sephepha lakho ngokwenza uvavanyo kwiPingdom:
umthwalo wephepha le-pingdom

I-Asynchronous Javascript ikuvumela ukuba ubhale ikhowudi exelela izinto ukuba zilayishwe emva iphepha lilayishwe ngokupheleleyo. Akukho kuxhomekeka! Ke, iphepha lakho lilayisha kwaye nje ukuba lugqityiwe, iscript esivelisayo esilayisha ezinye izinto-kule meko amaqhosha ethu okuhlala. Ukuba ungumphuhlisi, ungafunda inqaku elihle, Ukonqena ukulayishwa kweJavascript.

Nantsi i-snippet yendlela yokwenza ngokufanelekileyo kwi-Emil Stenström:

(function () {function async_load () {var s = document.createElement ('script'); s.type = 'text / javascript'; s.async = true; src = 'http://buttondomain.com /script.js '; var x = document.getElementsByTagName (' script ') [0]; x.parentNode. enye iwindow.addEventListener ('load', async_load, false);}) ();

Isiphumo kukuba ukudityaniswa komntu wesithathu kuphantsi okanye kuhamba kancinci, ayisoze ichaphazele umxholo wakho wephepha ukuba uvele. Ukuba ujonga umthombo wephepha lethu, uya kubona ukuba ndilayisha zonke izikripthi ezongezelelweyo zentlalo ndisebenzisa obu buchule. Inkqubo siphucule isantya semizuzwana kwindawo yethu -Kwaye ayikrwitshi ngexesha lokulayisha. Asikaguquki konke ukuxhomekeka kwethu kwangaphandle kuye I-Asynchronous Javascript, kodwa siya kuthi.

Ingaba ucinga ntoni?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda indlela idatha yakho yokubhaliweyo isetyenziswe ngayo.