When you have many JavaScript functions and you plan to use them on lots web pages, it is always advisable to go on them in a single file, and then allow that file on all page where those functions are needed. This way, you can better prepare them, you don't have to copy/paste the code again , and you'll be forced to write more concluded code for better integration and quantifiability.

Besides, introducing the usual JavaScript routines in external files acts your web pages uncluttered and search engine spiders and crawlers are able to arrive at the essential content easily. They don't have to make through tens of lines of scripts. In the first edition of my article I had excluded the process of making the external JavaScript files, but when one of my readers asked me how to do it, I had to re-write the article.

It's very easy. Use any text editor of your liking . Write the wanted code, and save the file with .js (dot js) extension. I'm going to give you a small example. Suppose your JavaScript file is "myjfuncs.js". and it has a function to return the larger number of the two provided as parameters you can just start with the function, no require to write So when we use one of its duties in a JavaScript:In this way, we can use all the complex functions contained in the myjfuncs.js file.