+ 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?

21st Mar 2020, 4:29 AM
Alfred Juma
Alfred Juma - avatar
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.
21st Mar 2020, 8:00 AM
Gordon
Gordon - avatar
+ 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.
21st Mar 2020, 4:30 AM
Gordon
Gordon - avatar
+ 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.
21st Mar 2020, 4:33 AM
Gordon
Gordon - avatar
+ 1
Gordon, a simple syntax will help
21st Mar 2020, 4:30 AM
Alfred Juma
Alfred Juma - avatar
+ 1
Went through it, now lets see some github code please Gordon
21st Mar 2020, 4:36 AM
Alfred Juma
Alfred Juma - avatar
+ 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.
21st Mar 2020, 1:38 PM
Gordon
Gordon - avatar
0
I am asking a question, I will come back to you. https://www.sololearn.com/Discuss/2208136/?ref=app
21st Mar 2020, 8:25 AM
Gordon
Gordon - avatar