Including other files: Difference between revisions

From Yate Documentation
Jump to navigation Jump to search
Created page with " Because the standard Javascript language does not have the notion of a script file we added some extensions to include a script file from another one. ===Syntax=== <pre> #i..."
 
 
Line 23: Line 23:
'''See also'''
'''See also'''
* [[Javascript]]
* [[Javascript]]
[[Category:Javascript]] [[Category:Programmers]]

Latest revision as of 13:31, 31 October 2013

Because the standard Javascript language does not have the notion of a script file we added some extensions to include a script file from another one.

Syntax

#include "file1.js"
#require "file2.js"

IMPORTANT: There's no semicolon at end, these are not Javascript instructions.

The #require form prevents repeated inclusion of same file. This is the preferred form unless you have special requirements.

The #include form includes the specified file unconditionally.

Limitations

Since the inclusion is performed at parsing time the file name must be a string literal, it cannot be a variable.

File inclusion cannot occur inside an instruction or function.

See also