← ClaudeAtlas

jquery-4-migrationlisted

Migrate a Drupal theme's JavaScript from jQuery 3 to jQuery 4 (as shipped by Drupal 11), on a Dockerized Makefile-driven project. Use when the user mentions jQuery 3→4, jQuery 4 deprecated/removed APIs ($.trim, $.isFunction, $.isArray, $.type, .bind/.delegate…), a jquery-deprecated / migrate polyfill, or "$.x is not a function" after an upgrade. Covers scanning custom + contrib JS, native conversions, rebuilding assets, and a scoped local polyfill for not-yet-compatible third-party libraries. IMPORTANT: all builds MUST go through Makefile/npm targets, never on the host.
JMAILLY/claude-migration-skills · ★ 0 · API & Backend · score 70
Install: claude install-skill JMAILLY/claude-migration-skills
# jQuery 3 → jQuery 4 migration (Drupal theme) Drupal 11 ships jQuery 4. All APIs deprecated since jQuery 3.x are **permanently removed**. Custom JS (typically under `web/themes/custom/<theme>/src/js/`) must be migrated. This works independently of the core bump: native replacements (`Array.isArray`, `String.prototype.trim`, `Date.now`…) exist regardless of the jQuery version, so you can migrate and test **while still on Drupal 10** (jQuery 3.x + polyfill). ## Golden rule: everything goes through the Makefile Never run `npm`/`gulp` directly on the host — use the targets inside the node container: | Need | Make target | |---|---| | Build assets | `make npm-build` | | Deploy built assets | `make gulp-deploy` | | Clear Drupal cache | `make cr` | | Shell in a container | `make shell` | ## The polyfill: understand before acting Many D10 projects include a **polyfill** re-implementing removed jQuery functions (`jquery-deprecated.js` / `polyfill.js`). Its presence means: 1. Theme code likely still depends on these APIs. 2. Two strategies: - **(A) Keep the polyfill** temporarily, migrate the calling code progressively, remove it at the end. Safest — **recommended**. - **(B) Migrate everything to native APIs and remove the polyfill** at once. Cleaner but riskier. Start with (A); remove the polyfill once `grep` confirms zero remaining usages. ## Removed API conversion table | Removed API | Native / jQuery 4 replacement | |---|---| | `$.isFunction(x)` / `$.fn.i