Tus Xaib Ceev thiab Asynchronous Javascript

asynchronous

Thaum kuv ua ntau txoj kev loj hlob, Kuv tsis cais kuv tus kheej tias tus tsim tawm muaj tseeb. Kuv tuaj yeem ua haujlwm thiab txav khoom nyob ib puag ncig ntawm nplooj ntawv thiab ua haujlwm rau. Tus tsim tawm tseeb to taub yuav ua li cas txhim kho qhov chaws kom nws thiaj li ua kom haum xeeb, tsis siv ntau yam khoom siv, thauj nrawm, hloov kho tau yooj yim tom qab thiab tseem ua haujlwm.

Qhov nyuaj tshaj plaws uas cov neeg lag luam muab tso rau yog ob qho muaj a vas sab vas sab heev thiab tseem suav kev sib xyaw ua ke thiab kev sib raug zoo uas yuav tsim kev vam khom sai npaum li cas koj lub xaib yuav thauj khoom. Ib qho piv txwv zoo li no kev khawmCov. Ntawm Martech, peb muaj cov nyees khawm social rau ntawm txhua nplooj ntawv ib sab ntawm lub site. Yog li… yog tias cov khoom siv Facebook thauj khoom qeeb ib hnub, nws ua rau peb lub xaib qeeb. Tom qab ntawd ntxiv Twitter, Pinterest, Tsis, thiab lwm yam rau qhov ntawd thiab koj lub xaib txoj kev thauj khoom sai yog txo rau qhov tsis muaj dab tsi.

Qhov ntawd yog lub npe hu ua synchronous loading. Koj yuav tsum ua kom tiav chaw thau khoom ib qho ua ntej koj thauj khoom tom ntej no. Yog tias koj muaj peev xwm thauj cov khoom asynchronously, koj tuaj yeem thauj khoom yog tsis muaj kev vam khom rau ib leeg. Koj tuaj yeem txhim kho koj lub xaib qhov nrawm nrawm los ntawm kev thauj khoom lub zog asynchronously. Qhov teeb meem yog tias cov ntawv sau tawm ntawm-lub-kem uas cov tuam txhab no muab rau koj yuav luag tsis tau qhov ua tiav khiav ntawm asynchronous.
asynchronous

Koj tuaj yeem pom dab tsi cuam tshuam rau koj nplooj ceev los ntawm kev sim ua tiav ntawm Pingdom:
pingdom nplooj ntawv load

Asynchronous Javascript tso cai rau koj sau cov cai uas qhia cov ntsaws cov khoom tom qab cov nplooj yog thauj tag. Tsis muaj kev tiv thaiv! Yog li, koj nplooj ntawv thau khoom thiab thaum nws ua tiav, ib tsab ntawv pib uas thauj lwm lub ntsiab - hauv qhov no peb cov nyees khawm kev sib raug zoo. Yog tias koj yog tus tsim khoom, koj tuaj yeem nyeem cov kab lus zoo, Puam Chaw Thauj Khoom Asynchronous Javascript.

Ntawm no yog qhov snippet ntawm yuav ua li cas thiaj ua tau zoo los ntawm Emil Stenström:

(muaj nuj nqi () {muaj nuj nqi async_load () {var s = document.createElement ('tsab ntawv'); s.type = 'ntawv nyeem / javascript'; s.async = tseeb; s.src = 'http://buttondomain.com /script.js '; var x = document.getElementsByTagName (' tsab ntawv ') [0]; x.parentNode.insertBefore (s, x);} yog (window.attachEvent) window.attachEvent (' onload ', async_load); lwm qhov rai.addEventListener ('load', async_load, cuav);}) ();

Qhov tshwm sim yog tias cov kev sib txuam hauv pawg thib peb no tau poob qis los yog khiav qeeb, nws yeej tsis cuam tshuam koj cov nplooj ntawv tseem ceeb los ntawm kev tshwm sim. Yog tias koj saib qhov ntawm peb nplooj ntawv, koj yuav pom tias kuv tab tom thauj khoom txhua tus ntawm cov ntawv sau ntxiv kev siv cov txheej txheem no. Tus txheej txheem txhim kho peb lub xaib tus ceev nrawm - thiab tsis daig thaum lub sijhawm thauj khoom. Peb tsis tau hloov tag nrho peb cov neeg sab nraud Asynchronous Javascript, tab sis peb yuav.

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.