简体   繁体   中英

Importing in plain JS file

I am trying to keep my files as basic as possible. Therefore in my html file I have:

<script src="js/binarytree_standardgrid_script.js"></script>

and then inside my binarytree_standardgrid_script.js file I would like to use: Ramda.js

How do I "import" Ramda.js or "include" Ramda.js without using node? or do I really neeed to use node?

And then I have another file called BinaryTree.js

The file structure is

    ./index.html 
    ./algorithms/BinaryTree.js
    ./js/binarytree_standardgrid_script.js

and inside the html file I call the binarytree_standardgrid_script.js by:

and inside that script I would like to be able to use BinaryTree.js and then also Ramda Library.

How can I do that in Javascript? Do I really need to use node?

Ok I found the solution:

Just put the scripts on the html page:

<script src="algorithms/BinaryTree.js"></script>

<script src="http://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>

<script src="js/binarytree_standardgrid_script.js"></script>

The classes and functions will then be available in the script file as long as it is not inside a function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM