Using OEOS Script Includes - fapnip/openeos GitHub Wiki
Eos doesn't have any way to easily include global javascript, requiring you to glob it altogether in its "Init Script".
OpenEOS allows you to mark any EVAL action in any page as a global script include. If the EVAL action contains //--oeos-js-include
, the EVAL action will be executed once on tease start. It will not be executed again, even if the page the EVAL is contained within is displayed.
Example: Put the following in an EVAL action in any page. The JavaScript in the EVAL will be loaded upon tease start, before the Init Script:
//--oeos-js-include
var myGlobalFunction = function() {
console.log('This global function was included on test start')
}
Notes:
- Includes are executed in alphabetical page order, then in EVAL action order within the given page. (For example, an include in a page with a name starting with "a" will execute before an include with a page starting with "s".)
- It is best to place includes in pages that are not otherwise accessed. (You never goto the page.)
The Dynamic Censor Demo has an example of how to use this feature in its x-js-censor-script
page.