-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronous XMLHttpRequest on the main thread is deprecated #5
Comments
Probably this means your stylesheet has a call on the doc() or document() function. If you want to avoid this kind of effect, you need to break the stylesheet execution up at appropriate points using call-template with ixsl:schedule-action so that the browser has a chance to respond to user interaction events. Michael Kay
|
Just FYI, recently some browser vendors wanted to get rid of synchronous XHR at all, so this is probably result of this effort -- you will get warning if you use synchronous XHR. But I don't expect they will remove this from platform soon. |
I don't really understand what you mean by "your stylesheet has a call on the doc() or document() function". Could you explain? |
If your stylesheet calls doc() or document() to retrieve an XML document from the server, Saxon (via GWT) translates that into a synchronoous XML HTTP request. There’s not really any practical alternative. Michael Kay
|
My stylesheet doesn't do that... it is one single (long) stylesheet containing everything. You say: But there are different styles in javascript for handling asynchronous function calls, like 'the nodejs way', or using promises. |
Any updates on this? It is the intention of the Saxon-CE developers to eliminate the synchronous load? Can I do my own xml and xsl loads (asynchronously) and then pass those to Saxon? |
First point: we’re not actually doing any active development on Saxon-CE at the moment. That doesn’t mean we’ve abandoned it, just that it’s not top of our priority list and we have limited resources. I don’t see any solution in sight to avoid a synchronous HTTP request if the stylesheet calls doc() or document(). But you can avoid this in your application if you know before the transformation starts what documents you want to load: you can load them yourself and supply them as transformation parameters. Michael Kay
|
Hi Michael,
What's the simplest change one can make to eliminate the warning? Can it be done natively with the Saxon object? |
I changed the code as follows. But my transform time went from 200ms to 8000ms. Why would how I load the xml and xsl change the transform time?
Before It was timed as follows:
|
I’m not entirely sure where the warning is coming from, but I think it may be purely because the browser detects the presence of Javascript code that does an asynchronous request, even if that code is not executed. If that’s the case then there’s not much we can do about it because the code is generated by GWT. Michael Kay |
I may have misread this, but aren’t the times for loading the documents included in your measurement in one case, and excluded in the other? If you do things asynchronously, then the costs aren't incurred at the point you make the request. Michael Kay
|
Hi Michael,
|
"Why would how I load the xml and xsl change the transform time?" If I recall correctly: If the XSLT request completes first, compilation can start while the XML is still being loaded. If the XML source request completes first then the transform starts as soon as the XSLT response completes and the XSLT source is compiled. This strategy can lead to significant time-saving. You could change your code to adopt this strategy, but I don't think it will prevent the deprecation warning that seems to be triggered even when Saxon-CE is only using asynchronous requests. |
Ok - that make sense. On a different note, I'm curious if there is any initiative to port Saxon On Sat, Aug 15, 2015 at 8:01 AM, Phil Fearon [email protected]
|
Rather depends on what happens to GWT. I’ve started thinking, however (no more than that) about an eventual replacement for Saxon-CE that is an XSLT runtime rather than a full XSLT interpreter; it would execute an intermediate representation of the stylesheet compiled server-side in advance. It might well be written natively in JS rather than compiled using GWT. Removing the GWT dependency would be liberating (and open up the possibility of a server-side engine under node-js) and I think we could get the whole thing down to a much more acceptable size. ES6 has some very nice features (I particularly like the class/method syntax) that makes this a much pleasanter prospect. Michael Kay |
Compiling to an intermediate representation that can run on Perhaps something like: I think the pieces are falling into place. I'd be happy to contribute some
On Sat, Aug 15, 2015 at 1:28 PM, Michael Kay [email protected]
|
When trying to use the javascript API
I got the following message in chromium:
"Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/."
The text was updated successfully, but these errors were encountered: