[
https://issues.jboss.org/browse/RF-12067?page=com.atlassian.jira.plugin.s...
]
Nicholas Oxhøj updated RF-12067:
--------------------------------
Description:
Hi,
I think there is a problem with the way that RichFaces loads external JavaScript files,
referenced in AJAX responses. The way it is done at the moment, the files are loaded *and
parsed* asynchronously. This is a problem if the files depend on being loaded in the
correct order.
As an example, I have a page with an OpenFaces DataTable which is not initially rendered,
but can be later rendered using the "reRender" attribute of an AJAX action. The
Openfaces DataTable requires two OpenFaces JavaScript files, util.js & ajaxUtil.js,
where the second depends on the first being loaded first. These files are included in the
<head> section of the AJAX response, in the correct order. But since they are then
loaded asynchronously, things will break if ajaxUtil.js finishes loading first.
I think you need to ensure, that the files are parsed in the same order as they appear in
the response.
The problem is mainly in the function _appendNewElements() in AJAX.js.
For HTML5 capable browsers, you should just be able to add set the "async"
property to "false" on the script element, before appending it to head as
described here: [HTML5 Async
Scripts|http://ie.microsoft.com/testdrive/Performance/AsyncScripts/Defaul...]
For non-HTML5 browsers, the only solution would probably be to modify the functionality a
bit, such that you would only generate and insert a new script tag, when the previous
script finished loading. Since appendNewHeadElements() already uses the scripts
"onload" and "onreadystatechange" to find out when _all_ scripts have
loaded, I suspect that it should be a relatively minor change to initially just insert the
_first_ script tag and then use these functions to insert the _next_ script tag when the
first has finished loading.
For an in-depth discussion of the problems and different solution strategies, see WHATWGs
[Dynamic Script Execution
Order|http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order]
Regards,
Nicholas Oxhøj
was:
Hi,
I think there is a problem with the way that RichFaces loads external JavaScript files,
referenced in AJAX responses. The way it is done at the moment, the files are loaded *and
parsed* asynchronously/in parallel. This is a problem if the files depend on being loaded
in the correct order.
As an example, I have a page with an OpenFaces DataTable which is not initially rendered,
but can be later rendered using the "reRender" attribute of an AJAX action. The
Openfaces DataTable requires two OpenFaces JavaScript files, util.js & ajaxUtil.js,
where the second depends on the first being loaded first. These files are included in the
<head> section of the AJAX response, in the correct order. But since they are then
loaded asynchronously, things will break if ajaxUtil.js finishes loading first.
I think you need to ensure, that the files are parsed in the same order as they appear in
the response.
The problem is mainly in the function _appendNewElements() in AJAX.js.
For HTML5 capable browsers, you should just be able to add set the "async"
property to "false" on the script element, before appending it to head as
described here: [HTML5 Async
Scripts|http://ie.microsoft.com/testdrive/Performance/AsyncScripts/Defaul...]
For non-HTML5 browsers, the only solution would probably be to modify the functionality a
bit, such that you would only generate and insert a new script tag, when the previous
script finished loading. Since appendNewHeadElements() already uses the scripts
"onload" and "onreadystatechange" to find out when _all_ scripts have
loaded, I suspect that it should be a relatively minor change to initially just insert the
_first_ script tag and then use these functions to insert the _next_ script tag when the
first has finished loading.
For an in-depth discussion of the problems and different solution strategies, see WHATWGs
[Dynamic Script Execution
Order|http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order]
Regards,
Nicholas Oxhøj
Load order of external JavaScript files referenced in AJAX responses
--------------------------------------------------------------------
Key: RF-12067
URL:
https://issues.jboss.org/browse/RF-12067
Project: RichFaces
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 3.3.3.Final
Reporter: Nicholas Oxhøj
Hi,
I think there is a problem with the way that RichFaces loads external JavaScript files,
referenced in AJAX responses. The way it is done at the moment, the files are loaded *and
parsed* asynchronously. This is a problem if the files depend on being loaded in the
correct order.
As an example, I have a page with an OpenFaces DataTable which is not initially rendered,
but can be later rendered using the "reRender" attribute of an AJAX action. The
Openfaces DataTable requires two OpenFaces JavaScript files, util.js & ajaxUtil.js,
where the second depends on the first being loaded first. These files are included in the
<head> section of the AJAX response, in the correct order. But since they are then
loaded asynchronously, things will break if ajaxUtil.js finishes loading first.
I think you need to ensure, that the files are parsed in the same order as they appear in
the response.
The problem is mainly in the function _appendNewElements() in AJAX.js.
For HTML5 capable browsers, you should just be able to add set the "async"
property to "false" on the script element, before appending it to head as
described here: [HTML5 Async
Scripts|http://ie.microsoft.com/testdrive/Performance/AsyncScripts/Defaul...]
For non-HTML5 browsers, the only solution would probably be to modify the functionality a
bit, such that you would only generate and insert a new script tag, when the previous
script finished loading. Since appendNewHeadElements() already uses the scripts
"onload" and "onreadystatechange" to find out when _all_ scripts have
loaded, I suspect that it should be a relatively minor change to initially just insert the
_first_ script tag and then use these functions to insert the _next_ script tag when the
first has finished loading.
For an in-depth discussion of the problems and different solution strategies, see WHATWGs
[Dynamic Script Execution
Order|http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order]
Regards,
Nicholas Oxhøj
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira