T
Tutorials
  • Introduction
  • What is jQuery?
  • Why jQuery?
  • How to add jQuery to web pages
  • jQuery Syntax
  • What is the Document Ready Event
  • jQuery Selectors
  • Functions In a Separate File
  • What are Events?
  • jQuery Syntax For Event Methods
  • Commonly Used jQuery Event Methods
  • Hide and Show effects
  • jQuery Toggle
  • jQuery Fading
  • jQuery Sliding Methods
  • animate() Method
  • jQuery stop() Method
  • jQuery Callback Functions
  • jQuery Method Chaining
Functions In a Separate File
By Aiden Barti @aidenbarti
Thu-04, May 2023

If your website contains a lot of pages, and you want your jQuery functions to be easy to maintain, you can put your jQuery functions in a separate .js file.

When we demonstrate jQuery in this tutorial, the functions are added directly into the <head> section. However, sometimes it is preferable to place them in a separate file, like this (use the src attribute to refer to the .js file):

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="my_jquery_functions.js"></script>
</head>

Leave a comment
comments 0