Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a single javascript file be used by multiple html files?

I have a javascript file main.js and five html files 1.html,2.html,3.html,4.html,5.html I want to access the javascript file main.as in all files . I have used in all of the five but I'm not able to access it . Is it possible to share the .js file among the html files.

Plz reply,

Thanks in advance

Prashant Dubey

like image 832
Prashant Dubey Avatar asked Jul 12 '26 21:07

Prashant Dubey


2 Answers

Yes, it is entirely possible. That's the point of being able to have a JS file instead of having to embed all the code in the HTML.

like image 165
Quentin Avatar answered Jul 14 '26 13:07

Quentin


yes this is well possible. You merely have to include

<script type="text/javascript" src="main.js"></script>

in your HTML files, preferably near the bottom (for faster rendering). What have you done so far?

like image 34
Tom Bartel Avatar answered Jul 14 '26 11:07

Tom Bartel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!