Skip to content
hlaCk edited this page Dec 28, 2018 · 1 revision

The Document Load Event

Execute function after the document is finished loading (Trigger when the page is fully loaded).


Method 1: Default way.

_z.load(function);

  • _z to access UnderZ library.
  • load method/action name.
  • function function to execute after the DOM is fully loaded. It can be anonymous function

Returns: _z Object


Method 2: Shorter way.

Make sure that no other library use _1 sign.

_1(function);

  • _1 to access .load() method in UnderZ library.
  • function function to execute after the DOM is fully loaded. It can be anonymous function

Returns: _z Object


Examples

// change document title when DOM is fully loaded
_z.load(function () {
	document.title = "Document is ready";
});

// print the title first thing in <body> when DOM is fully loaded
_1(function () {
	_z("body").prepend(document.title);
});


// you can also use function name
function newTitle() {
	document.title = "DOM is fully loaded";
}
_1(newTitle);

// this returning only when DOM is fully loaded.
function returnTest() {
	return "Only when DOM is fully loaded";
}

_z.load( returnTest ); // _z
_1( returnTest ); // _z

_z.load( returnTest ) === _z; // true
_1( returnTest ) === _z; // true

Use your own way.

Clone this wiki locally