Asynchronous JavaScript is a technique to load JavaScript asynchronously using async and defer attributes or script tag injection. Not to be confused with AJAX.
Questions tagged [asynchronous-javascript]
91 questions
18
votes
5 answers
Two different ways of putting the script at the bottom - what are the differences?
What are the differences between the two solutions below ?
In particular, is there a good reason to favour 2 over 1. (note: Please assume the name of the script to load is known. The question is just about if there is value in creating a minimal…
![](../../users/profiles/246394.webp)
Zo72
- 13,193
- 16
- 65
- 98
4
votes
1 answer
Nodejs + Mongodb: find data after aggregation
I'm a new to Nodejs and MongoDB.
Here is a sample of my dataset:
{
'name': ABC,
'age':24,
'gender':male,
...
}
Generally speaking, what I want to do is to aggregate data before using them to find different data clusters.
To be specific, I…
![](../../users/profiles/6338494.webp)
Lixing Liang
- 377
- 1
- 4
- 9
4
votes
1 answer
Asynchronous java script loading is showing error
Asynchronous java script loading is showing the following error:
Attribute name "async" associated with an element type "script" must
be followed by the ' = ' character. + jsf
I found this in my JSF2.4 application which uses template file…
![](../../users/profiles/2581174.webp)
Valsaraj Viswanathan
- 1,027
- 3
- 22
- 43
3
votes
2 answers
Why use `URL.createObjectURL(blob)` instead of `image.src`?
Q1. In the context of asynchronous JavaScript and the need to ‘fetch’ data from the client-side, why can’t we just edit our image elements by its attribute src?
Q2. Why is the Blob conversion process necessary to go through?
Q3. What is the blob…
![](../../users/profiles/13098409.webp)
hyfyline
- 33
- 1
- 4
3
votes
4 answers
Passing a named function in Javascript
How do you pass a named function with parameters without calling it.
Right now the only solution I have seems like a hack but it is to pass an unnamed function that will call the named function.
callback(function(){foo(params);})
Is there a better…
![](../../users/profiles/4949848.webp)
Qasim Ahmed
- 177
- 1
- 10
3
votes
5 answers
Defer loading of JavaScript - Uncaught ReferenceError: $ is not defined
I use google code to defer loading javascript (google pages)
But I have some inline javascripts such as:
And this gives me:
Uncaught ReferenceError: $ is not…
![](../../users/profiles/3176336.webp)
Manic Depression
- 922
- 1
- 14
- 27
2
votes
1 answer
How can I make jQuery replaceWith() "non-blocking" (async)?
I'm using the function replaceStr() to replace some strings in the body tag. If the html page is small, the replacing is not noticeable. But if the html page is bigger and more complex you notice it. The replacing is blocking the browser. My…
![](../../users/profiles/13012001.webp)
Oliver
- 79
- 6
2
votes
1 answer
AWS SDK wait for asynchronous call to complete?
The AWS SDK documentation is not very clear about when/how/if asynchronous service calls can be made synchronous. For example, this page (https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/calling-services-asynchronously.html)…
![](../../users/profiles/150050.webp)
aaa90210
- 8,944
- 12
- 43
- 78
2
votes
2 answers
Render called before setState updates state
Is there any way to make sure render is called after setState actually updates the state? From my knowledge, setState is asynchronous. I have tried putting render as the callback to setState, but it still renders before the state is updated.
HTML…
![](../../users/profiles/5832000.webp)
Vappor Washmade
- 255
- 3
- 14
1
vote
2 answers
Why can't I access api fetch response?
I'm new to asynchronous processes and I don't understand why my current method of trying to store a response from a fetch request to an api is not working.
I'm building and Angular app, where I have a api.service.ts file where I define my fetch…
![](../../users/profiles/13096596.webp)
docphilstone
- 21
- 2
1
vote
0 answers
Readline passed a callback on.close execution order
Here I'm using the Readline module inside a function that executes a callback function on.close. It executes in the expected order (the code on.close, then the code in the callback passed to it, this can be seen with the console.log statements),…
![](../../users/profiles/10424452.webp)
Mick
- 171
- 1
- 8
1
vote
1 answer
Execute javascript async function and return result in selenium
I am trying to execute the following script in selenium
result = driver.execute_script('let result; await axe.run().then((r)=> {result=r}); return result;')
But it is returning
javascript error: await is only valid in async function
I also…
![](../../users/profiles/7937050.webp)
archit wagle
- 15
- 6
1
vote
1 answer
How to wait my custom command finish, then executing remaining Cypress commands
I'm getting trouble with Cypress asynchronous mechanism. I have a custom command that is placed in this file
class HeaderPage {
shopLink = 'a[href="/angularpractice/shop"]'
homeLink = ''
navigateToShopPage() {
…
![](../../users/profiles/6467384.webp)
Hoang
- 35
- 3
1
vote
1 answer
React Native - How to deal with asynchronism with AsyncStorage
I am facing to asynchronism problem :
I create a user in firebase, generating a unique ID for it.
I get this unique ID.
I call an async function to persist this ID with AsyncStorage method.
Problem : The asyncStorage method is called before I get…
![](../../users/profiles/9623528.webp)
Gautier Méheust
- 13
- 4
1
vote
3 answers
Trouble fetching data with Async/Await
Hi I'm trying to fetch a country's data after which I want to fetch the names for its neighboring countries.
import React from 'react';
export default function DetailsRoute({ match }) {
const [countryData, setCountryData] =…
![](../../users/profiles/13926327.webp)
Sapinder
- 183
- 10