CrossBrowdy - Basic tutorial

General

More

Any JavaScript file can be lazy loaded this way:


	//Includes the desired script:
	CB_includeJSFile
	(
		//Filepath:
		"path/to/script.js",
		//Callback when the file has been loaded successfully. Optional. Belongs to "callbackOk":
		function (filePath, callbackOk, callbackError, timeoutMs)
		{
			CB_console("File loaded!"); //Note that "callbackError" could still be called if we wanted to.
		},
		//Callback when there is any error including the file or it cannot be included after the defined timeout. Optional. Belongs to "callbackError":
		function (filePath, callbackOk, callbackError, timeoutMs)
		{
			CB_console("File could not be loaded on time!"); //Note that "callbackOk" could still be called if we wanted to.
		},
		//Timeout limit in milliseconds. Optional (it will use the value of the "CB_includeJSFile_TIMEOUT_MS_DEFAULT" constant as default). Belongs to "timeoutMs":
		95000,
		//Defines whether to load the file asynchronously or not. Optional (it will be true as default). Belongs to "asynchronously":
		true
	);

If needed, CrossBrowdy version and other things can be checked easily:


	CB_console("CrossBrowdy version is " + CB_VERSION);
	CB_console("Script path used by CrossBrowdy: " + CB_scriptPath);
	CB_console(CB_this); //Shows the "this" context used by CrossBrowdy.

Check the API documentation to read more about some global functions and variables.

Go back to Guides & Tutorials













Share