Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Client Scripting
Expertise: Beginner
Feb 17, 2000



Application Security Testing: An Integral Part of DevOps

Place JavaScript In Separate Files


I want to create a library of generic JavaScript functions. Is it possible to write different functions in different files, and use the functions within other files by "including" these files? Like in C, you can use the #include directive to include other functions.


Yes, you can put your JavaScript into files that you reference from multiple pages. You should make sure that your JavaScript code files use the .js extension. In addition, your shared code library should be stored in a directory on your Web server that is accessible over the Web, just like an image. The syntax for including your code is:

Make sure to include the trailing tag.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date