-1

In php website I am using different javascript functions in different pages for example page a calls functions 1,2,3 and page b calls functions 2, 4, 6 and page c calls functions 3, 6 can I place all javascript functions in one file

1
  • yes. you will get advantage of reduced http hits to server. in your case if you have proper expiration and cache headers for your javascript file, you can reduce 60% traffic for that resource. Commented Mar 11, 2015 at 7:41

1 Answer 1

0

Yes. In HTML you can include an external Javascript file like this:

<script src="js/six_util_functions.js"></script>

So as long as your PHP outputs that in the right place, you should have no trouble calling functions 1-6 from anywhere in your HTML pages.

Not the answer you're looking for? Browse other questions tagged or ask your own question.