Use onLoad and beforeAppear correctly

You may be able to improve performance by limiting the amount of processing that has to be done by the browser by avoiding additional coding when using onLoad and beforeAppear, since the more code that is executed at this point, slower and longer the page load time may appear.

Also, do not make synchronous endpoint calls in beforeAppear or onLoad since rendering will be blocked until they return. An example of good practice of beforeAppear follows:

beforeAppear: function(page) {
	var self = this;
	setTimeout(function () {
		self.pause(2000)
		self.messagge("Pause Completed")
	},
	500);

},
pause function(millis) {
	var date = new Date();
	var curDate = null;
	do {
		curDate = new Date();
	}
	while (curDate - date < millis);
	}

For more information, see Understand widgets.