Hi Daniel,

Thanks for raising this, your intuition about the overlap between `async` and 
`defer` implementations is correct. They do share conceptual similarities, 
especially around non-blocking script execution. However, the implementation 
paths diverge in meaningful ways, particularly in how the parser interacts with 
script execution timing.

To clarify the current state:

  *   We’ve implemented `async` support for SVG scripts by extending the 
existing functionality already available for XHTML. This was feasible without 
modifying the XML parser itself because the async path leverages the 
`NotifyWhenLoaded()` mechanism. This method temporarily halts the parser, 
executes the script, and then resumes parsing once execution completes. Since 
this behavior was already supported for XHTML, we were able to reuse it for SVG 
without touching sensitive XML parsing code.
  *   In contrast, `defer` requires a more complex orchestration. Specifically, 
it involves maintaining a queue of pending scripts that must be executed only 
after the document has finished parsing. This queuing logic, essentially a 
deferred execution pipeline, is not currently implemented for XHTML in the XML 
parser. Supporting defer would require changes to the XML parsing 
infrastructure to track and manage these deferred scripts, which is why we’ve 
held off on implementing it for SVG at this time.

So yes, the `async` implementation was possible without modifying the code 
maintainers prefer to avoid, while `defer` would necessitate deeper changes to 
the XML parser’s behavior.

Hope this helps clarify the decision. Happy to discuss further if needed!

Thanks,
Virali


From: Daniel Bratell <[email protected]>
Sent: 29 August 2025 12:59
To: Daniel Clark <[email protected]>; blink-dev <[email protected]>
Cc: Virali Purbey <[email protected]>; Chromestatus 
<[email protected]>; Philip Jägenstedt <[email protected]>; 
[email protected] <[email protected]>; [email protected] 
<[email protected]>; [email protected]
Subject: Re: [EXTERNAL] Re: [blink-dev] Re: Intent to Ship: Support async 
attribute for SVG <script> element


Shipping just async is of course an option and thanks for investigating this! 
Though I feel like there is still something I don't quite understand. Was the 
async implementation possible without changing the code the maintainers do not 
want touched? It might be an uninformed belief, but I thought the defer and 
async implementations would overlap. The main difference is that defer 
guarantees execution order (complexity) and that async can happen at any time 
(complexity).

/Daniel
On 2025-08-27 23:52, 'Dan Clark' via blink-dev wrote:
Thanks Virali for looking deeper into supporting `defer` and for the design 
doc<https://docs.google.com/document/d/15qFv33dwAxloXAeMa3ZEuw5iGZxAwXKcBry_gFCq1UA/edit?tab=t.0#heading=h.urwq2nczx234>
 on what that would look like. I see that there was discussion on this over at 
loading-dev and I want to link that context here so we can decide how to move 
forward: 
https://groups.google.com/u/0/a/chromium.org/g/loading-dev/c/abRvsaclp0Q

Since the loading owners are opposed to adding `defer` support to XML documents 
at this time, it seems the remaining choices are to ship just `async` or to 
ship neither.

I'm still undecided. Daniel Bratell, you first raised the question about 
`defer`, I'm curious to know what you think about shipping just `async` now 
that it looks like there might be hard block to also supporting `defer`.

-- Dan
On Thursday, July 10, 2025 at 3:07:24 AM UTC-7 Virali Purbey wrote:
Updating the status for supporting the defer attribute in the SVG element.

We recognize the importance of shipping both async and defer attributes 
together, and we are planning accordingly. Supporting the defer attribute 
requires additional work on integrating it within XMLParser, which will demand 
more time and effort. Therefore, this Intent to Ship (I2S) will be paused while 
we address this dependency.

We will provide updates on the I2S once we have made progress on supporting the 
defer attribute or if we encounter further challenges in its implementation. At 
this moment, the timeline for completion remains uncertain.

Please let me know if you have any questions or concerns regarding the same.

Thanks,
Virali

________________________________
From: Daniel Bratell <[email protected]>
Sent: Wednesday, May 21, 2025 21:06
To: Virali Purbey <[email protected]>; Alex Russell 
<[email protected]>; blink-dev <[email protected]>
Cc: Chromestatus <[email protected]>; Philip Jägenstedt 
<[email protected]>; Yoav Weiss <[email protected]>
Subject: Re: [EXTERNAL] Re: [blink-dev] Re: Intent to Ship: Support async 
attribute for SVG <script> element


As I see it, we should try to ship async and defer at the same time unless 
there is a strong reason to not do so, just to avoid developer confusion, and 
support matrix complexity.



/Daniel


On 2025-05-20 05:52, Virali Purbey wrote:
I am working on it to see if it is not blocked on another bug Module scripts 
should be supported in XHTML documents [40518469] - 
Chromium<https://issues.chromium.org/issues/40518469>. But thanks for bringing 
this up. As Alex suggested, if there is a need to add defer, we will be ready 
for this.

Regarding updating the spec, there is one github action item that is expected 
to update the spec Should support async and defer attributes on script elements 
· Issue #918 · w3c/svgwg<https://github.com/w3c/svgwg/issues/918>. If no one is 
working on it, I might take this up.

Thanks,
Virali
​
[Image removed by sender.]<https://github.com/w3c/svgwg/issues/918>
Should support async and defer attributes on script 
elements<https://github.com/w3c/svgwg/issues/918>
You signed in with another tab or window. Reload to refresh your session. You 
signed out in another tab or window. Reload to refresh your session. You 
switched accounts on another tab or window.
github.com<http://github.com/>
​

________________________________
From: Alex Russell <[email protected]>
Sent: Monday, May 19, 2025 23:40
To: blink-dev <[email protected]>
Cc: Daniel Bratell <[email protected]>; blink-dev <[email protected]>; 
Chromestatus <[email protected]>; Virali Purbey 
<[email protected]>; Philip Jägenstedt <[email protected]>; Yoav Weiss 
<[email protected]>
Subject: [EXTERNAL] Re: [blink-dev] Re: Intent to Ship: Support async attribute 
for SVG <script> element

You don't often get email from [email protected]. Learn why this is 
important<https://aka.ms/LearnAboutSenderIdentification>
Good question, Daniel. I'd also like to understand if we've got signals from 
developers on this. I can see a strong case for it, but we should be led by 
developer needs. The 3 users in the crbug are a good start, but have we tried 
to survey a larger population?

Best,

Alex
On Wednesday, May 14, 2025 at 8:27:02 AM UTC-7 Daniel Bratell wrote:

What is the status of the defer attribute? It is mentioned in the same SVG spec 
annotation and async and defer are similar in many ways so it would make sense 
to support both or none.

/Daniel
On 2025-05-14 17:19, Philip Jägenstedt wrote:
On Wed, May 14, 2025 at 4:45 PM Yoav Weiss (@Shopify) <[email protected]> 
wrote:

On Wednesday, May 14, 2025 at 10:19:43 AM UTC+2 Chromestatus wrote:
Contact emails [email protected]

Explainer None

Specification 
https://svgwg.org/svg2-draft/interact.html#ScriptElement:~:text=%E2%80%98script%E2%80%99%20element-,SVG%202%20Requirement%3A,Consider%20allowing%20async/defer%20on%20%E2%80%98script%E2%80%99.,-Resolution%3A

I don't see this in the spec, other than the annotation saying that we should 
add it at some point. I understand that we're shipping last here, but it's 
still out of process to ship without an actual specification that allows us to 
know what we're shipping is interoperable..
Design docs
https://docs.google.com/document/d/146iVXAKrBpzGYBc88EqxVLRDZyBT13ERVTs5POXcTYA/edit?usp=sharing

Summary

The SVGScriptElement interface in SVG 2.0 introduces the async attribute, 
similar to the HTMLScriptElement. This attribute allows scripts to be executed 
asynchronously, improving the performance and responsiveness of web 
applications that utilize SVG.


Blink component 
Blink>SVG<https://issues.chromium.org/issues?q=customfield1222907:%22Blink%3ESVG%22>

TAG review None

TAG review status Not applicable

Risks


Interoperability and Compatibility

This is already supported in Firefox


Gecko: Shipped/Shipping 
(https://developer.mozilla.org/en-US/docs/Web/API/SVGScriptElement)

WebKit: No signal (https://github.com/WebKit/standards-positions/issues/490)

Web developers: Positive Three users have noted they are impacted by the CrBug.

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it 
has potentially high risk for Android WebView-based applications?

None


Debuggability

The functionality of the async attribute is similar to how they are used in 
HTML <script> element, so no further devtools support is required.


Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, 
ChromeOS, Android, and Android WebView)? Yes

Is this feature fully tested by 
web-platform-tests<https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md>?
 Yes

wpt.fyi link: https://wpt.fyi/results/svg/interact/scripted/async-01.svg

This test currently passes in Chromium (and fails in Safari). It that the right 
test?

It seems like this is because the default view is experimental. The test fails 
on Chrome stable as expected:
https://wpt.fyi/results/svg/interact/scripted/async-01.svg?label=master&label=stable&aligned
--
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAARdPYcBYPqkWsoJ%3DtYbqwBZ5Rt-iKLREe7jBEqOVP%3D7iUWO_w%40mail.gmail.com<https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAARdPYcBYPqkWsoJ%3DtYbqwBZ5Rt-iKLREe7jBEqOVP%3D7iUWO_w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/1f122256-0920-4448-a7db-e6df07324915n%40chromium.org<https://groups.google.com/a/chromium.org/d/msgid/blink-dev/1f122256-0920-4448-a7db-e6df07324915n%40chromium.org?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/SI2P153MB05078EAB5A7439DDCD206B58C13AA%40SI2P153MB0507.APCP153.PROD.OUTLOOK.COM.

Reply via email to