Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision |
custom:javascript:lib:index [2018/12/27 19:22] – Fill out the library usage examples more, fixed some typos 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: |
someLib.property = true; | someLib.property = true; |
someLib.do_something(); | someLib.do_something(); |
| |
| ==== Index ==== |
| Articles documenting the usage of specific JavaScript Libraries are listed here: |
| {{indexmenu>.}} |
| |
===== See Also ===== | ===== See Also ===== |
* [[:custom:javascript:|JavaScript]] | * [[:custom:javascript:|JavaScript]] |
| * [[http://cvs.synchro.net/cgi-bin/viewcvs.cgi/exec/load/|load Directory contents from Synchronet CVS]] |
| |
{{tag>javascript}} | {{tag>javascript}} |
| |
Back to top