Integrating a JavaScript File Into a Web Application
- Updated2024-05-31
- 2 minute(s) read
Integrating a JavaScript File Into a Web Application
Connect a JavaScript file to your web application and call functions you defined in a JavaScript Library Interface (JSLI) in your web application.
Before you begin, create and configure a JLI.
-
Import the JavaScript file(s) you want to use into your web application.
- Save your project.
- On the Project Files tab, right-click a web application document or library component document (.gcomp) and select Import files.
- Navigate to the JavaScript file(s) you want to add and click Open. Click Copy to close the Copy existing file(s) dialog box.
-
Integrate the JavaScript file into your web application.
-
Open the JSLI document associated with the JavaScript file and enter the relative path to the JavaScript file in the HTML script and link dependencies form field.
Example:
<script src="library.js"></script>
Note The JavaScript file must be in the same component as the JSLI document and must be marked as Always include in the component document. - Click Apply Changes.
-
Open the JSLI document associated with the JavaScript file and enter the relative path to the JavaScript file in the HTML script and link dependencies form field.
-
Add the entry points you defined in the JSLI to any web application in your project.
- Open the WebVI in which you want to call the JavaScript function.
- On the diagram palette, click . Click the folder with the name of your JSLI document to show each entry point you defined in that JSLI.
- Drop the entry points you want to use on the diagram.
- Wire the entry points and complete the diagram.
- Run the WebVI. Input data passes from the diagram to the JavaScript code, and output data returns from the JavaScript code to the diagram.
Related Information
- Defining Calls to JavaScript Functions using a JavaScript Library Interface
To call JavaScript functions in your web application, define calls to the JavaScript functions using a JavaScript Library Interface (JSLI) document.