Skip to content
Maximilian Berkmann edited this page Oct 5, 2016 · 9 revisions

Welcome to the EssenceJS wiki!

Getting started

Offline usage

To use EssenceJS locally (with all the required modules installed), you need to have at least the following structure in your code:

A. Using HTML and JS in one single file

<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="path/to/essence.js"></script>
	<script type="text/javascript" defer>
	function Init (stackLayer) {
		if (typeof Essence !== "undefined") {
			//Your code for when the browser is ready to use your EssenceJS code
		} else if (stackLayer > 3) {
			console.log("Wow, hold on ! %d stack layers down !!", stackLayer);
			setTimeout("Init()", 5);
		} else {
			console.warn("EssenceJS is not currently available !");
			Init(stackLayer? stackLayer + 1: 1);
		}
	}
	</script>
</head>
<body onpageshow="Init()">
	
</body>
</html>

B. Having HTML and JS in seperate files

index.html (the name doesn't matter)

<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="path/to/essence.js"></script>
	<script type="text/javascript" src="path/to/yourscript.js"></script>
</head>
<body onpageshow="Init()">
	
</body>
</html>

yourscript.js

function Init (stackLayer) {
	if (typeof Essence !== "undefined") {
		//Your code for when the browser is ready to use your EssenceJS code
	} else if (stackLayer > 3) {
		console.log("Wow, hold on ! %d stack layers down !!", stackLayer);
		setTimeout("Init()", 5);
	} else {
		console.warn("EssenceJS is not currently available !");
		Init(stackLayer? stackLayer + 1: 1);
	}
}

Online usage

To use EssenceJS with an internet access and (without downloading anything), you need to have at least the following structure in your code:

A. Using HTML and JS in one single file

<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="http://berkmann18.github.io/rsc/essence.js"></script>
	<script type="text/javascript" defer>
	function Init (stackLayer) {
		if (typeof Essence !== "undefined") {
			//Your code for when the browser is ready to use your EssenceJS code
		} else if (stackLayer > 3) {
			console.log("Wow, hold on ! %d stack layers down !!", stackLayer);
			setTimeout("Init()", 5);
		} else {
			console.warn("EssenceJS is not currently available !");
			Init(stackLayer? stackLayer + 1: 1);
		}
	}
	</script>
</head>
<body onpageshow="Init()">
	
</body>
</html>

B. Having HTML and JS in seperate files

index.html

<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="http://berkmann18.github.io/rsc/essence.js"></script>
	<script type="text/javascript" src="path/to/yourscript.js"></script>
</head>
<body onpageshow="Init()">
	
</body>
</html>

yourscript.js

function Init (stackLayer) {
	if (typeof Essence !== "undefined") {
		//Your code for when the browser is ready to use your EssenceJS code
	} else if (stackLayer > 3) {
		console.log("Wow, hold on ! %d stack layers down !!", stackLayer);
		setTimeout("Init()", 5);
	} else {
		console.warn("EssenceJS is not currently available !");
		Init(stackLayer? stackLayer + 1: 1);
	}
}

Tutorials

More