Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision |
custom:javascript:lib:index [2018/12/27 20:00] – List the JS lib child documents (just one for now) digital man | custom:javascript:lib:index [2019/01/11 19:07] – [Require vs. Load] Added comment about exit() use in libraries digital man |
---|
The ''require()'' function (added in Synchronet v3.17) is identical in usage to ''load()'' with the exception that it will //conditionally// load and execute the script only if the property name argument (specified just after the filename argument) is not already defined in the target scope. This prevents redundant loading/compilation/execution of libraries shared among multiple modules. For large libraries or commonly used libraries, consider using ''require()'' instead of ''load()'' to enhance performance and avoid the possible erroneous redefinition of ''const'' variables during subsequent ''load()'' operations of the same library. | The ''require()'' function (added in Synchronet v3.17) is identical in usage to ''load()'' with the exception that it will //conditionally// load and execute the script only if the property name argument (specified just after the filename argument) is not already defined in the target scope. This prevents redundant loading/compilation/execution of libraries shared among multiple modules. For large libraries or commonly used libraries, consider using ''require()'' instead of ''load()'' to enhance performance and avoid the possible erroneous redefinition of ''const'' variables during subsequent ''load()'' operations of the same library. |
| |
| ===== exit ===== |
| Libraries should **not** (normally) call the global ''exit()'' method or else the calling script(s) will also terminate, possibly unexpectedly. |
===== Styles ===== | ===== Styles ===== |
There are 3 main //styles// of JavaScript libraries included with Synchronet: | There are 3 main //styles// of JavaScript libraries included with Synchronet: |
Back to top