This file provides context for AI coding assistants working with this repository.
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversing and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
Tech Stack: JavaScript, HTML
This repository contains the core jQuery library, which is designed to be used in browser environments but also supports Node.js, browser extensions, and other non-browser environments.
The build system for jQuery uses npm and Grunt.
Key commands:
npm install: Install dependenciesnpm run build: Build jQuery (equivalent togrunt)grunt: Build a full version of jQuerygrunt -help: List all available Grunt tasks
- Ensure you have Node.js/npm and git 1.7 or later installed.
- Clone the repository:
git clone git://github.com/jquery/jquery.git
- Enter the jquery directory:
cd jquery - Install dependencies:
npm install
- Install Grunt CLI globally (recommended):
npm install -g grunt-cli
- Make your changes in the
src/directory. - Run
gruntto build jQuery. - The built version will be in the
dist/subdirectory.
To run tests:
npm testThis command runs Grunt and then executes the test suite.
Add new dependencies to package.json and then run npm install.
jquery/
├─ build/ # Build-related files
├─ external/ # External libraries and tools
├─ src/ # Source code for jQuery
│ ├─ ajax/ # AJAX functionality
│ ├─ attributes/ # Attribute manipulation
│ ├─ core/ # Core jQuery functionality
│ ├─ css/ # CSS manipulation
│ ├─ data/ # Data storage
│ ├─ effects/ # Animation and effects
│ ├─ event/ # Event handling
│ ├─ manipulation/ # DOM manipulation
│ ├─ traversing/ # DOM traversal
│ └─ ...
├─ test/ # Test files (not visible in provided tree)
└─ dist/ # Built files (created after build)
- Modular structure: jQuery is organized into modules (ajax, attributes, core, etc.) for maintainability.
- Use of immediate function invocations for scoping.
- Extensive use of method chaining in the API design.
- Cross-browser compatibility considerations throughout the codebase.
- Ensure you're using the latest Node.js version for compatibility.
- Run
gruntafter making changes to rebuild jQuery. - When creating custom builds, be aware of module dependencies (e.g., excluding 'css' will remove all modules depending on it).
- Contribute to the correct repository: this is for jQuery Core only, not plugins or documentation.
jQuery uses QUnit for testing. Test files are organized to match the structure of the src/ directory. The project emphasizes thorough testing, with tests for both API functionality and internal implementations.
The repository uses Travis CI for continuous integration. The .travis.yml file (not visible in the provided tree) likely contains the CI configuration.
Must Follow:
- NEVER hardcode secrets, API keys, or credentials
- NEVER log sensitive data (PII, tokens, passwords)
- NEVER commit .env files or secrets
- [OK] Use environment variables for all secrets
- [OK] Validate and sanitize all user inputs
- [OK] Follow the principle of least privilege
Additionally for jQuery:
- Sanitize all inputs when manipulating the DOM to prevent XSS attacks.
- Use
.text()instead of.html()when inserting user-generated content. - Be cautious when using
$.ajax()to prevent CSRF vulnerabilities.
- Run linting:
grunt jshint - Run tests:
npm test - Build:
grunt - Verify: Check that your changes don't break existing functionality and follow the jQuery Core Style Guide.
Generated by Forter AI Platform