views:

590

answers:

2

It is recommended that js files be included on the bottom of the page. I'm using Telerik Rad Ajax controls that emit js includes on top of the page. Is there a way to force it to emit js includes at the bottom of the page?

+1  A: 

A solution to this problem may be to use JQuery to load the script asynchronously like this:


$(function () {
  $.getScript("script.js", function () { // You may skip the second argument
    alert("Done loading");
  });
});

You may wait a while too like this:


$(function () {
  setTimeout(function () {
    $.getScript("script.js");
  }, 500);
});
knut
+1  A: 

If you place your RadAjaxManager as the last control in your markup, it will emit the JavaScript at the bottom of the page.

However as far as the placement of the included references to the scriptresource.axd(s). There's no setting to change that.

Jose Basilio
also if you try to add javascript in codebehind use RegisterStartupScript function, which will put your js file right before closing form tag </form>.
dev.e.loper