D
Denis
Hello,
Maybe somebody already solved this task. I need to load JS
asynchronously without blocking browser. This means that I do not need
to block browser to load/render during loading script. The simple
construction to do this:
jsJSNode = document.createElement(“script”);
jsJSNode.type = “text/javascript”;
jsJSNode.src = “http:// den-01/Default.aspx“;
document.body.appendChild(jsMyNode);
works fine in IE6 & IE7. (By fine I mean – IE loads script
asynchronously and DOENT block the browser)
But the same code works synchronously in Firefox (blocks FF). The
strange situation because many websites say that download with be
asynchronously (e.g. http://ntt.cc/2008/02/10/4-ways-to-dynamically-load-external-javascriptwith-source.html).
My Default.aspx is:
protected void Page_Load(object sender, EventArgs e)
{
Thread.Sleep(200000); //just for show that FF is blocked
Response.Buffer = true;
Response.Clear();
Response.ContentType = "application/x-javascript";
Response.Write(“var var1 = 1;”);
}
And with this Default.aspx FF hangs. Does anybody knows how to solve
this task? (I can’t use XHR because there will be _crossdomain_ call
and this call will be blocked with FF anyway). I know that there is
attribute “defer” but it works for IE only.
Want to clarify task again: I need to get small JS that will contain
variable to my page. But this data is not critical and if server that
provides this data will go down for some reason I want to show page
anyway (the page and this data JS are in different domains). With IE
everything is fine but doesn’t work with FF (other browsers are not
critical at this moment)
Thank you,
Denis
Maybe somebody already solved this task. I need to load JS
asynchronously without blocking browser. This means that I do not need
to block browser to load/render during loading script. The simple
construction to do this:
jsJSNode = document.createElement(“script”);
jsJSNode.type = “text/javascript”;
jsJSNode.src = “http:// den-01/Default.aspx“;
document.body.appendChild(jsMyNode);
works fine in IE6 & IE7. (By fine I mean – IE loads script
asynchronously and DOENT block the browser)
But the same code works synchronously in Firefox (blocks FF). The
strange situation because many websites say that download with be
asynchronously (e.g. http://ntt.cc/2008/02/10/4-ways-to-dynamically-load-external-javascriptwith-source.html).
My Default.aspx is:
protected void Page_Load(object sender, EventArgs e)
{
Thread.Sleep(200000); //just for show that FF is blocked
Response.Buffer = true;
Response.Clear();
Response.ContentType = "application/x-javascript";
Response.Write(“var var1 = 1;”);
}
And with this Default.aspx FF hangs. Does anybody knows how to solve
this task? (I can’t use XHR because there will be _crossdomain_ call
and this call will be blocked with FF anyway). I know that there is
attribute “defer” but it works for IE only.
Want to clarify task again: I need to get small JS that will contain
variable to my page. But this data is not critical and if server that
provides this data will go down for some reason I want to show page
anyway (the page and this data JS are in different domains). With IE
everything is fine but doesn’t work with FF (other browsers are not
critical at this moment)
Thank you,
Denis