Can we use async attribute for script loaded dynamically?
Can we use async attribute to load script asynchronously for script loaded dynamically?
html5 css3
add a comment |
Can we use async attribute to load script asynchronously for script loaded dynamically?
html5 css3
Can you elaborate a bit more on what you mean byscript loaded dynamically?
– Dinesh Pandiyan
Nov 24 '18 at 6:08
Yes.Will “Async” attribute loads script asynchronously when used for a script that is dynamically added to the DOM
– user3190467
Nov 24 '18 at 6:11
Possible duplicate of Is the "async" attribute/property useful if a script is dynamically added to the DOM?
– Dinesh Pandiyan
Nov 24 '18 at 6:19
add a comment |
Can we use async attribute to load script asynchronously for script loaded dynamically?
html5 css3
Can we use async attribute to load script asynchronously for script loaded dynamically?
html5 css3
html5 css3
edited Nov 24 '18 at 11:07
Roman Pokrovskij
4,323125081
4,323125081
asked Nov 24 '18 at 5:56
user3190467user3190467
43
43
Can you elaborate a bit more on what you mean byscript loaded dynamically?
– Dinesh Pandiyan
Nov 24 '18 at 6:08
Yes.Will “Async” attribute loads script asynchronously when used for a script that is dynamically added to the DOM
– user3190467
Nov 24 '18 at 6:11
Possible duplicate of Is the "async" attribute/property useful if a script is dynamically added to the DOM?
– Dinesh Pandiyan
Nov 24 '18 at 6:19
add a comment |
Can you elaborate a bit more on what you mean byscript loaded dynamically?
– Dinesh Pandiyan
Nov 24 '18 at 6:08
Yes.Will “Async” attribute loads script asynchronously when used for a script that is dynamically added to the DOM
– user3190467
Nov 24 '18 at 6:11
Possible duplicate of Is the "async" attribute/property useful if a script is dynamically added to the DOM?
– Dinesh Pandiyan
Nov 24 '18 at 6:19
Can you elaborate a bit more on what you mean by
script loaded dynamically?– Dinesh Pandiyan
Nov 24 '18 at 6:08
Can you elaborate a bit more on what you mean by
script loaded dynamically?– Dinesh Pandiyan
Nov 24 '18 at 6:08
Yes.Will “Async” attribute loads script asynchronously when used for a script that is dynamically added to the DOM
– user3190467
Nov 24 '18 at 6:11
Yes.Will “Async” attribute loads script asynchronously when used for a script that is dynamically added to the DOM
– user3190467
Nov 24 '18 at 6:11
Possible duplicate of Is the "async" attribute/property useful if a script is dynamically added to the DOM?
– Dinesh Pandiyan
Nov 24 '18 at 6:19
Possible duplicate of Is the "async" attribute/property useful if a script is dynamically added to the DOM?
– Dinesh Pandiyan
Nov 24 '18 at 6:19
add a comment |
2 Answers
2
active
oldest
votes
By script loaded dynamically, if you mean adding javascript code dynamically to your page, then the answer is No.
async attribute can only be used on loading external scripts that are referred to via a URL specified in src attribute.
The async attribute is only for external scripts (and should only be used if the src attribute is present)
Example, You can load only scripts like this asyncronously
<script src="external-file.js" async></script>
add a comment |
It is an interesting point.
Here is an example, some Similar StackOverflow questions, and jQuery Document link For use of Async attribute
Example:
<!DOCTYPE html>
<html>
<head>
<title>Async Test Attribute</title>
</head>
<body>
<script src="async_demo.js" async></script>
<h2>Welcome to Demo!</h2>
<script>
console.log('HELLO NON-async');
</script>
</body>
</html>
async_demo.js
console.log('HELLO Async');
Screencast for above code: https://hareen-nipl.tinytake.com/sf/MzEwNzYzOV85MzEzNTgz
Async jQuery : http://forum.jquery.com/topic/jquery-ajax-async-vs-html5-script-async
W3School Document: https://www.w3schools.com/tags/att_script_async.asp
Similar StackOverflow questions
Add defer or async attribute to dynamically generated script tags via javascript
Is the "async" attribute/property useful if a script is dynamically added to the DOM?
Please comment down below if you have any questions for the same.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455565%2fcan-we-use-async-attribute-for-script-loaded-dynamically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
By script loaded dynamically, if you mean adding javascript code dynamically to your page, then the answer is No.
async attribute can only be used on loading external scripts that are referred to via a URL specified in src attribute.
The async attribute is only for external scripts (and should only be used if the src attribute is present)
Example, You can load only scripts like this asyncronously
<script src="external-file.js" async></script>
add a comment |
By script loaded dynamically, if you mean adding javascript code dynamically to your page, then the answer is No.
async attribute can only be used on loading external scripts that are referred to via a URL specified in src attribute.
The async attribute is only for external scripts (and should only be used if the src attribute is present)
Example, You can load only scripts like this asyncronously
<script src="external-file.js" async></script>
add a comment |
By script loaded dynamically, if you mean adding javascript code dynamically to your page, then the answer is No.
async attribute can only be used on loading external scripts that are referred to via a URL specified in src attribute.
The async attribute is only for external scripts (and should only be used if the src attribute is present)
Example, You can load only scripts like this asyncronously
<script src="external-file.js" async></script>
By script loaded dynamically, if you mean adding javascript code dynamically to your page, then the answer is No.
async attribute can only be used on loading external scripts that are referred to via a URL specified in src attribute.
The async attribute is only for external scripts (and should only be used if the src attribute is present)
Example, You can load only scripts like this asyncronously
<script src="external-file.js" async></script>
answered Nov 24 '18 at 6:16
Dinesh PandiyanDinesh Pandiyan
2,5981926
2,5981926
add a comment |
add a comment |
It is an interesting point.
Here is an example, some Similar StackOverflow questions, and jQuery Document link For use of Async attribute
Example:
<!DOCTYPE html>
<html>
<head>
<title>Async Test Attribute</title>
</head>
<body>
<script src="async_demo.js" async></script>
<h2>Welcome to Demo!</h2>
<script>
console.log('HELLO NON-async');
</script>
</body>
</html>
async_demo.js
console.log('HELLO Async');
Screencast for above code: https://hareen-nipl.tinytake.com/sf/MzEwNzYzOV85MzEzNTgz
Async jQuery : http://forum.jquery.com/topic/jquery-ajax-async-vs-html5-script-async
W3School Document: https://www.w3schools.com/tags/att_script_async.asp
Similar StackOverflow questions
Add defer or async attribute to dynamically generated script tags via javascript
Is the "async" attribute/property useful if a script is dynamically added to the DOM?
Please comment down below if you have any questions for the same.
add a comment |
It is an interesting point.
Here is an example, some Similar StackOverflow questions, and jQuery Document link For use of Async attribute
Example:
<!DOCTYPE html>
<html>
<head>
<title>Async Test Attribute</title>
</head>
<body>
<script src="async_demo.js" async></script>
<h2>Welcome to Demo!</h2>
<script>
console.log('HELLO NON-async');
</script>
</body>
</html>
async_demo.js
console.log('HELLO Async');
Screencast for above code: https://hareen-nipl.tinytake.com/sf/MzEwNzYzOV85MzEzNTgz
Async jQuery : http://forum.jquery.com/topic/jquery-ajax-async-vs-html5-script-async
W3School Document: https://www.w3schools.com/tags/att_script_async.asp
Similar StackOverflow questions
Add defer or async attribute to dynamically generated script tags via javascript
Is the "async" attribute/property useful if a script is dynamically added to the DOM?
Please comment down below if you have any questions for the same.
add a comment |
It is an interesting point.
Here is an example, some Similar StackOverflow questions, and jQuery Document link For use of Async attribute
Example:
<!DOCTYPE html>
<html>
<head>
<title>Async Test Attribute</title>
</head>
<body>
<script src="async_demo.js" async></script>
<h2>Welcome to Demo!</h2>
<script>
console.log('HELLO NON-async');
</script>
</body>
</html>
async_demo.js
console.log('HELLO Async');
Screencast for above code: https://hareen-nipl.tinytake.com/sf/MzEwNzYzOV85MzEzNTgz
Async jQuery : http://forum.jquery.com/topic/jquery-ajax-async-vs-html5-script-async
W3School Document: https://www.w3schools.com/tags/att_script_async.asp
Similar StackOverflow questions
Add defer or async attribute to dynamically generated script tags via javascript
Is the "async" attribute/property useful if a script is dynamically added to the DOM?
Please comment down below if you have any questions for the same.
It is an interesting point.
Here is an example, some Similar StackOverflow questions, and jQuery Document link For use of Async attribute
Example:
<!DOCTYPE html>
<html>
<head>
<title>Async Test Attribute</title>
</head>
<body>
<script src="async_demo.js" async></script>
<h2>Welcome to Demo!</h2>
<script>
console.log('HELLO NON-async');
</script>
</body>
</html>
async_demo.js
console.log('HELLO Async');
Screencast for above code: https://hareen-nipl.tinytake.com/sf/MzEwNzYzOV85MzEzNTgz
Async jQuery : http://forum.jquery.com/topic/jquery-ajax-async-vs-html5-script-async
W3School Document: https://www.w3schools.com/tags/att_script_async.asp
Similar StackOverflow questions
Add defer or async attribute to dynamically generated script tags via javascript
Is the "async" attribute/property useful if a script is dynamically added to the DOM?
Please comment down below if you have any questions for the same.
edited Nov 24 '18 at 6:36
answered Nov 24 '18 at 6:30
HareenHareen
263
263
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455565%2fcan-we-use-async-attribute-for-script-loaded-dynamically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you elaborate a bit more on what you mean by
script loaded dynamically?– Dinesh Pandiyan
Nov 24 '18 at 6:08
Yes.Will “Async” attribute loads script asynchronously when used for a script that is dynamically added to the DOM
– user3190467
Nov 24 '18 at 6:11
Possible duplicate of Is the "async" attribute/property useful if a script is dynamically added to the DOM?
– Dinesh Pandiyan
Nov 24 '18 at 6:19