Saurin Yanar Gizo da Asynchronous Javascript

asynchronous

Duk da yake ina samun ci gaba sosai, ban sanya kaina a matsayin mai tasowa na gaskiya ba. Zan iya shiryawa kuma in motsa abubuwa a shafi kuma in sanya shi aiki. Mai haɓaka na gaskiya ya fahimci yadda ake haɓaka lambar don a iya auna ta, ba ta karɓi albarkatu da yawa, loda da sauri, a sauƙaƙe a gyara daga baya kuma har yanzu yana aiki.

Matsayi mai wahala wanda aka saka yan kasuwa shine duka biyun suna da sauri yanar gizo kuma har yanzu kun haɗa abubuwan haɗin kai da abubuwan zamantakewar da zasu iya haifar da dogaro kan yadda saurin shafinku zai ɗora. Daya daga cikin irin wadannan misalan ita ce maɓallin zamantakewa. A kan Martech, muna da maɓallin zamantakewar akan kowane shafi a shafin. Don haka… idan kayan Facebook suka danyi jinkiri wata rana, yana rage shafin mu. Bayan haka sai a kara Twitter, Pinterest, Buffer, da sauransu.sai hakan kuma damar shafin ka na saurin yin sauri ya ragu ba komai.

Wannan an san shi azaman aiki tare. Dole ne ku gama lodin abu ɗaya kafin kun loda abu na gaba. Idan kuna iya loda abubuwa asynchronously, kuna iya loda abubuwa ba tare da dogaro da junan ku ba. Kuna iya inganta saurin shafin ku ta hanyar ɗora abubuwan asynchronously. Matsalar ita ce rubutun da ke cikin akwatin waɗanda waɗannan kamfanoni ke ba ku kusan ba a taɓa inganta su don tafiyar da asynchronous ba.
asynchronous

Kuna iya ganin abin da yake tasiri ga saurin shafinku ta hanyar gudanar da gwaji akan Pingdom:
shafin shafi na pingdom

Asynchronous Javascript ba ka damar rubuta lambar da ke faɗi abubuwan da za su ɗora bayan shafin ya cika lodi. Babu dogaro! Don haka, shafinku yana lodaita kuma da zarar ya kammala, rubutun zai fara aiwatar da lodi ga sauran abubuwan - a wannan yanayin maballin zamantakewar mu. Idan kai mai haɓaka ne, zaka iya karanta babban labarin, Ragwan Loading Asynchronous Javascript.

Ga takaitaccen yadda ake yin sa da kyau daga Emil Stenström:

(aiki () {aiki async_load () {var s = document.createElement ('rubutun'); s.type = 'rubutu / javascript'; s.async = gaskiya ne; s.src = 'http://buttondomain.com /script.js '; var x = document.getElementsByTagName (' rubutun ') [0]; x.parentNode.insertBefore (s, x);} idan (window.attachEvent) window.attachEvent (' a ɗora ', async_load); wani window.addEventListener ('kaya', async_load, ƙarya);}) ();

Sakamakon shine idan waɗannan haɗin haɗin ɓangare na uku suna ƙasa ko suna tafiya a hankali, bazai taɓa tasirin ainihin shafin yanar gizonku ba daga bayyana. Idan ka duba tushen shafinmu, za ka ga cewa ina loda dukkan ƙarin rubutun zamantakewar jama'a da ke amfani da wannan fasahar. Tsarin inganta saurin shafin mu - kuma baya shaƙewa yayin lodin. Ba mu canza duk dogaronmu na waje ba Asynchronous Javascript, amma za mu yi.

Me kuke tunani?

Wannan shafin yana amfani da Akismet don rage spam. Koyi yadda aka sarrafa bayanan bayaninka.