+ 1
Is there a way to link two javascript files?
Javascript is normally linked to a html file using the script tag, but is the a way(s) to link a javascript file to another javascript file?
7 Answers
0
https://gorgorgordon.github.io/MySoloLearnCodes/exportimport.html
Should be using module.js in same directory, not sure why have 404 error
the repo
https://github.com/gorgorgordon/MySoloLearnCodes
exportimport.html and module.js
hope someone come to teach me when free.
+ 2
Yes.
import, export
You export your modular in one js files:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
You import it in anothe:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
Modularity is essential in large projects where scripts are heavily reused.
+ 2
I edit the first answer with links to MDN examples.
If that's not sufficient, let me know, I'll code an example for you in Github.
+ 1
Gordon, a simple syntax will help
+ 1
Went through it, now lets see some github code please Gordon
+ 1
It is solved. You can the demo now.
Look at
exportimport.html
and
module.js
the output is in the console, use Dev Tool to view.
0
I am asking a question, I will come back to you.
https://www.sololearn.com/Discuss/2208136/?ref=app