Welcome Guest. Sign in or Signup


How to load some Java Script files dynamically and delay calling of document.ready method until all the files are loaded?

Asked by: 2208 views d) Performance


You can dynamically download some JS files when the page loads based on some condition as follows. Do this in your script block:

var somecondition = true;
if(somecondition === true)

	$.getScript("www.yoursite/yourJsFile.js", function () {
		// Downloaded the js file
$(document).ready(function() {
  	// This call will be delayed untill the above js file is loaded.

Comments on Question