I have seen many ways to include a JS file in another JS file, but all of them seem to require the files to be located on a server, as opposed to on the local drive. Is there any way to include a JS file in another while keeping all files on the local drive?
-
1In what sort of environment is the code running? A browser running a local HTML file? Node?CertainPerformance– CertainPerformance2021-08-10 04:17:06 +00:00Commented Aug 10, 2021 at 4:17
-
It is running in a local HTML file, but functions from the included js file will be needed in the other, so adding another <script> tag with a different src will not workTetraPengwin– TetraPengwin2021-08-10 04:21:26 +00:00Commented Aug 10, 2021 at 4:21
-
1It should, have you tried it? Just make sure the scripts run in the correct order. Yeah, it's not so intuitive, but top-level variables in one script file will be accessible by any other script file.CertainPerformance– CertainPerformance2021-08-10 04:22:16 +00:00Commented Aug 10, 2021 at 4:22
-
ah, it seems i made a typo in the file name, classic programming mistake, it does now workTetraPengwin– TetraPengwin2021-08-10 04:25:33 +00:00Commented Aug 10, 2021 at 4:25
-
And that my friend is why we love copy paste so much :)Mark Baijens– Mark Baijens2021-08-10 04:52:23 +00:00Commented Aug 10, 2021 at 4:52
Add a comment
|