| name | jquery4-modern |
| description | Modern jQuery 4.0 coding standards and migration guide. This skill should be used when writing, reviewing, or migrating jQuery code to ensure compatibility with jQuery 4.0+ and adherence to modern best practices. Covers deprecated API replacements, event handling patterns, AJAX with async/await, performance optimization, and TypeScript integration. |
jQuery 4.0 Modern Coding Skill
This skill provides guidance for writing modern jQuery code compatible with jQuery 4.0.0+ (released January 2026).
When to Use This Skill
- Writing new jQuery code in projects using jQuery 4.0+
- Migrating legacy jQuery code from versions 1.x-3.x to 4.0
- Reviewing jQuery code for deprecated API usage
- Optimizing jQuery performance
- Integrating jQuery with TypeScript
Critical: Banned APIs in jQuery 4.0
The following APIs were removed in jQuery 4.0 and must never be used. Replace with native JavaScript equivalents:
| Banned API | Replacement |
|---|
$.isArray() | Array.isArray() |
$.parseJSON() | JSON.parse() |
$.trim() | str.trim() |
$.type() | typeof / instanceof |
$.now() | Date.now() |
$.isNumeric() | Number.isFinite() |
$.isFunction() | typeof fn === 'function' |
$.isWindow() | obj === window |
$.camelCase() | Custom function or lodash |
$.nodeName() | element.nodeName |
Also removed from prototype: $elems.push(), $elems.sort(), $elems.splice() — use [].method.call($elems, ...) instead.
Core Coding Patterns
Selector Best Practices
const $container = $('#container')
const $items = $container.find('.item')
$('div.container').addClass('active')
$('div.container').find('.item')
Event Handling
$container.on('click', '.item', (e) => {
e.preventDefault()
console.log($(e.currentTarget).data('id'))
})
$(() => {
initApp()
})
$element.click(handler)
$element.bind('click', handler)
$(document).ready(function () {})
AJAX with async/await
async function fetchData(endpoint) {
try {
const data = await $.ajax({
url: endpoint,
method: 'GET',
dataType: 'json',
})
return data
} catch (error) {
console.error('API Error:', error)
throw error
}
}
$.ajax({ url: '/api', dataType: 'jsonp' })
DOM Manipulation
const html = items.map((item) => `<li>${item.name}</li>`).join('')
$list.append(html)
$checkbox.prop('checked', true)
$input.prop('disabled', false)
items.forEach((item) => $list.append(`<li>${item.name}</li>`))
Animation
Prefer CSS transitions with class manipulation over jQuery animations:
$element.addClass('fade-in')
$element.animate({ scrollTop: position }, 300)
ES Modules Import
jQuery 4.0 supports ES modules natively:
import $ from 'jquery'
Detailed References
For comprehensive API migration tables, performance patterns, and TypeScript integration, see:
references/api-migration.md - Complete deprecated API replacement guide
references/patterns.md - Modern coding patterns with examples
Code Review Checklist
When reviewing jQuery code, verify:
- No banned APIs - Check for $.isArray, $.trim, $.parseJSON, etc.
- Cached selectors - Same selector should not be called multiple times
- Event delegation - Use .on() with delegation for dynamic elements
- Async/await for AJAX - Avoid callback-style $.ajax
- Native JS utilities - Prefer Array.isArray(), JSON.parse(), etc.
- CSS animations - Prefer class-based transitions over .animate()