Is it possible to associate more than one external javascript file to a single page? If so, when calling a function within one of the files would you use the file name extension?
>> "Is it possible to associate more than one external javascript file to a single page?"
yes
e.g.
<script type="text/javascript" src="foo.js"></script>
<script type="text/javascript" src="bar.js"></script>
>> "If so, when calling a function within one of the files would you use the file name extension?"
no, they are included as if they were written on the same page. you reference them by their name, and all function names must be unique.
e.g.
if foo.js contains method foo() and bar.js contains method bar(), you simply call foo() or bar()
Make sure you don't have variables or functions in one of the files that are named the same as variables or functions within the other. This would cause a conflict, and could lead to very ambiguous results, or code not working at all.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.