Skip to content

Conversation

RafaelJohn9
Copy link
Contributor

@RafaelJohn9 RafaelJohn9 commented Jul 2, 2025

Changes

Context

jQuery has not been meaningfully updated in over a decade. The previous version in use , jQuery 1.7.1 (released in 2011) , predates widespread support for modern JavaScript APIs. It was last updated in this project around 2013, and since then, no further upgrades were made despite over 50 releases and critical improvements in the jQuery ecosystem.

This long-standing neglect created growing technical debt:

  • Increasing incompatibility with modern development tools
  • Accumulation of deprecated patterns (.bind(), .click())
  • Potential security and performance concerns
  • Poor developer experience when debugging or extending JS

While the site continued to function thanks to jQuery Migrate and browser backward compatibility, this was not sustainable maintenance .


Why Upgrade Now?

We are modernizing the JavaScript foundation to:

  • Improve compatibility with current and future browser standards
  • Leverage bug fixes and performance improvements from jQuery 3.x
  • Enable use of modern jQuery features (e.g. improved .on(), better event delegation)
  • Support upcoming enhancements that depend on reliable, up-to-date tooling
  • Remove reliance on deprecated APIs that hinder maintainability
  • Align with security best practices by using actively supported versions

jQuery 3.x dropped support for legacy browsers (IE 6–8), which we no longer need to support. This allows us to benefit from a leaner, faster, and more predictable codebase.


Migration Strategy

This upgrade was done incrementally to ensure stability:

  1. Added jQuery Migrate 1.2.1 to detect deprecations
  2. Refactored legacy event bindings (.click().on(), .bind().on())
  3. Upgraded to jQuery 3.7.1 + jQuery UI 1.14.1 with modern Migrate
  4. Verified functionality across all interactive components
  5. Removed Migrate after confirming no deprecation warnings
  6. Cleaned up outdated asset comments in application.js

All changes preserve existing behavior. The result is a safer, more maintainable JavaScript foundation.


This work closes a long-overdue maintenance gap and sets the stage for more confident, modern front-end development.

@dscho
Copy link
Member

dscho commented Jul 3, 2025

You will most likely have to follow this guidance, in particular using jquery-migrate.

Also, the structure of these commits is chronological, in dear need of becoming logical instead. Keep an eye on reviewability. Hiding the change that drops jquery.defaultvalue in a different commit is no good, in particular when the commit message does not even explain nor provide references justifying this drop.

@RafaelJohn9 RafaelJohn9 force-pushed the refactor/update/jquery branch 2 times, most recently from 3f3ec70 to cb66948 Compare July 3, 2025 20:49
@RafaelJohn9
Copy link
Contributor Author

hey @dscho ,

on jquery.defaultValue its seems that it hasn't been maintained for a while: https://github.com/cloudchen/jquery.defaultValue

@RafaelJohn9 RafaelJohn9 force-pushed the refactor/update/jquery branch from db70fe3 to a98da04 Compare July 4, 2025 10:03
@RafaelJohn9 RafaelJohn9 marked this pull request as ready for review July 4, 2025 10:06
@dscho
Copy link
Member

dscho commented Jul 6, 2025

on jquery.defaultValue its seems that it hasn't been maintained for a while: https://github.com/cloudchen/jquery.defaultValue

That's excellent information, which dearly wants to go into the commit message.

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still convinced that you will most likely have to follow this guidance, in particular using jquery-migrate.

Either you did (but didn't talk about it in the commit messages, which you should, though), or you didn't (but you should).

Speaking of commit messages: For something as consequential as a JQuery update from an ancient version to a current one, you definitely need to up your commit message writing fu.
Please follow the guidance in https://github.blog/2022-06-30-write-better-commits-build-better-projects/ to improve it, in particular with a strong focus on this part:

  What you’re doing Why you’re doing it
High-level (strategic) Intent (what does this accomplish?) Context (why does the code do what it does now?)
Low-level (tactical) Implementation (what did you do to accomplish your goal?) Justification (why is this change being made?)

@dscho
Copy link
Member

dscho commented Jul 6, 2025

on jquery.defaultValue its seems that it hasn't been maintained for a while: https://github.com/cloudchen/jquery.defaultValue

That's excellent information, which dearly wants to go into the commit message.

Okay, after mulling it over a bit and git grep -i defaultvalue-ing, I come to a totally different conclusion: jquery.defaultValue has not been updated in quite a while. But that's because it is perfect, not because it isn't maintained. It does its job as it's supposed to do, and before you remove anything like that, you need to make sure that it is not used (otherwise your PR needs to be rejected out of hand). And it is used...

@RafaelJohn9 RafaelJohn9 force-pushed the refactor/update/jquery branch from a98da04 to c88f696 Compare August 4, 2025 20:32
@RafaelJohn9 RafaelJohn9 force-pushed the refactor/update/jquery branch from c88f696 to cf473bf Compare August 17, 2025 20:26
@RafaelJohn9 RafaelJohn9 requested a review from dscho August 17, 2025 20:26
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks already a lot better, but there is still stuff to do.

@@ -1,5 +1,5 @@
---
name: "giggle"
name: "giggle (no longer under active development)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change do in the PR to "Refactor/update/jquery"? (Which, by the way, is a much improvable description for what you are trying to accomplish.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @dscho ,


commit 9381210304dcaa02f1a3836134beb9683e12fff9
Author: Jonathan Ballet <[email protected]>
Date:   Sat Jun 21 18:58:42 2025 +0200

    GUI: giggle is not longer in active development
    
    The website points to https://gitlab.gnome.org/Archive/giggle, which is marked as "archived" ; [latest tag 0.7 is 12 years old](https://gitlab.gnome.org/Archive/giggle/-/tags) now.


I'm not the one who sneaked that commit in

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelJohn9 you may have rebased it, it has you as committer on record:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh, yea, my bad,

@RafaelJohn9
Copy link
Contributor Author

Hey @dscho , I used Jquery Migrate plugin, though I removed it after updating the deprecated parts,

would you recommend, leaving it inside the repo even after the upgrade ?

@dscho
Copy link
Member

dscho commented Sep 2, 2025

Hey @dscho , I used Jquery Migrate plugin, though I removed it after updating the deprecated parts,

would you recommend, leaving it inside the repo even after the upgrade ?

I would not recommend leaving it inside, but I would strongly suggest to start documenting what was done.

If you use jQuery Migrate, for example, I would have expected an initial commit to add it, to describe in its commit message what that plugin does (with a helpful link to the website) and why it was used in the first place. I would have expected the next commits to do a good job describing what problems the plugin showed and how they were resolved. The final commit I would have expected to be the one to remove the jQuery Migrate Plugin, stating that its job is done now and the migration is complete.

That would also have prevented forcing any reader to guess as to what has been done and having to pry vital information e.g. about the plugin and its use in a subsequent conversation. If I would not have asked, the details about how this PR came about would be lost. That story should have been written down in the commit messages to begin with, though. If it wasn't written down, it's as if it had never happened.

@RafaelJohn9 RafaelJohn9 force-pushed the refactor/update/jquery branch 3 times, most recently from c233c14 to 76644af Compare September 2, 2025 09:49
dscho added a commit to dscho/git-scm.com that referenced this pull request Sep 2, 2025
This branch comes from git#2022.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho
Copy link
Member

dscho commented Sep 2, 2025

Hmm. Something is telling me that this is not working as expected...
image


<script src="{{ relURL "js/jquery-1.7.1.min.js" }}"></script>
<script src="{{ relURL "js/jquery-ui-1.8.18.custom.min.js" }}"></script>
<script src="https://code.jquery.com/jquery-migrate-3.4.1.min.js"></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be v1.4.1 first, to upgrade across the jQuery v1.9.x boundary?

And, as per the documentation:

In your web page, load this plugin after the script for jQuery: [...]

That problem is highly likely to be the root cause of:

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelJohn9 Please integrate dscho@631599f.

Also, please split this change apart: Adding jQuery Migrate is, logically speaking, a very very different kind of change than upgrading the jQuery version.

Also document (in the commit message) that the guidance is to upgrade in two steps, first cross the v1.9 boundary, then the v3 boundary.

Then cross them in that order, via two separate commits.

Also, please do use the opportunity to switch away from the self-hosted jquery*.js files to the CDN ones as recommended by the jQuery project itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and the commit at the end that removes jQuery Migrate again is missing...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll first add the v1.9 migrate then, methodically move to v3 boundary

I'll also add the last commit to remove the jQuery Migrate 🤝

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

Once that's done, could you reword the PR title so that it reads a bit easier? Something like "Upgrade from woefully outdated jQuery version".

To elaborate on what motivates this change, the "Context" in the PR description should not be left empty but say something about potentially wanting to use newer jQuery features, benefit from bug fixes and support for newer browsers, apart from it just being poor workmanship to neglect central components for years.

There is also enough room in that empty space to describe when jQuery was last updated, and how frequently it was updated before that time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, forgot about that 😅 ,

thank you for your patience

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your persistence and stamina! I know I ask a lot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelJohn9 please ping me when it's done, I will then use it as part of the merge commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dscho , improved the PR description 🤝

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! It's now part of the (immutable) commit history: f847b39

dscho added a commit to dscho/git-scm.com that referenced this pull request Sep 4, 2025
This branch comes from git#2022.

Signed-off-by: Johannes Schindelin <[email protected]>
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on 76644af!


<script src="{{ relURL "js/jquery-1.7.1.min.js" }}"></script>
<script src="{{ relURL "js/jquery-ui-1.8.18.custom.min.js" }}"></script>
<script src="https://code.jquery.com/jquery-migrate-3.4.1.min.js"></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafaelJohn9 Please integrate dscho@631599f.

Also, please split this change apart: Adding jQuery Migrate is, logically speaking, a very very different kind of change than upgrading the jQuery version.

Also document (in the commit message) that the guidance is to upgrade in two steps, first cross the v1.9 boundary, then the v3 boundary.

Then cross them in that order, via two separate commits.

Also, please do use the opportunity to switch away from the self-hosted jquery*.js files to the CDN ones as recommended by the jQuery project itself.

Comment on lines 13 to 14
//= require jquery-1.7.1.min
//= require jquery-ui-1.8.18.custom.min
//= require jquery-3.7.1.min
//= require jquery-ui-1.14.1.min
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line of the commit message talks about adding two files. That's not the only change this commit makes, though, is it? It upgrades at the same time.

Let's just stop vendoring in the jQuery .js files. There are perfectly fine CDN versions of them; As a bonus, browsers can rely on the same .js files across sites, they don't need to cache a separate copy just for git-scm.com.

@RafaelJohn9 RafaelJohn9 changed the title Refactor/update/jquery Upgrade from woefully outdated jQuery version Sep 5, 2025
Upgrade jQuery from 1.7.1 to 1.9.1 and jQuery UI from 1.8.18 to 1.9.1 to
bridge toward a modern codebase. While 1.9.1 is still outdated by today's
standards, it introduces critical deprecation warnings and improves
compatibility with newer APIs, serving as a necessary intermediate step
before a full jump to jQuery 3.x.

Importantly, this commit adds jQuery Migrate 1.2.1 from the official CDN
to detect and log deprecated usage patterns that would otherwise break
silently during future upgrades. Migrate will surface issues like:
- Calls to deprecated methods (.live(), .bind() in certain contexts)

These warnings are essential for identifying technical debt in our
existing JavaScript (e.g., in application.js)
and planning safe refactors.

This is Step 1 of a phased migration strategy:
1. Upgrade to jQuery 1.9.1 + Migrate → current commit
2. Audit console warnings and modernize code
3. Upgrade to jQuery 3.7.1 with jquery-migrate-3.4.1
4. Remove Migrate once all deprecations are resolved

The use of CDN-hosted assets simplifies version management and ensures
we’re not bundling outdated copies.

Note: Source map 404s may appear (jquery.min.map) — these are harmless
and expected for older jQuery versions. We will address them in a later
upgrade when moving to modern, actively supported releases.
…ethods

Replace all instances of direct event binding methods (.click(), .focus(),
.bind(), .blur(), etc.) with the modern .on() API across the codebase.

The jQuery .on() method has been the recommended way to attach event
handlers since jQuery 1.7 (2011), superseding:
- .bind()
- .live() (removed in 1.9)
- .delegate()
- shorthand methods (.click(), .hover()) when delegation or cleanup is needed

While the shorthand methods still work, using .on() consistently provides:
- A single, unified pattern for event attachment
- Clear intent for both direct and delegated events
- Better compatibility with future jQuery versions
- Easier event namespace management and removal (.off())

This change touches multiple modules:
- GitTurns20: popstate handling and tagline click counter
- Search: focus, blur, keydown, and result interaction
- Dropdowns: toggle activation via click
- Forms: input selection
- Downloads: OS filter navigation
- DarkMode: toggle button interaction
- ScrollToTop: scroll monitoring and click behavior

Notable improvements:
- $(window).bind('popstate', ...) → $(window).on('popstate', ...): aligns with current best practices
- $("#tagline").click(...) → .on('click', ...): enables future delegation if needed
- $(document).keydown(...) → .on('keydown', ...): consistent event model
- $('#scrollToTop').click(...) → .on('click', ...): unified pattern across UI components

Additionally:
- Fixed event trigger in keyboard shortcut handler: now uses .trigger('focus') instead of direct .focus() to ensure consistent event flow
- Preserved event argument (e) and logic (e.preventDefault(), timeStamp checks) — no behavioral changes
- All selectors and functionality remain intact; this is a syntactic and maintainability upgrade

This refactor was guided by warnings from jQuery Migrate and is part of the larger migration plan:
1. Add jQuery Migrate → done
2. Fix deprecated patterns (like .bind(), .click()) → this commit
3. Upgrade to jQuery 3.7.1
4. Remove Migrate when clean

The code remains functionally identical, but is now more maintainable,
consistent, and future-proof. No regressions expected.

See: https://api.jquery.com/on/
See: https://github.com/jquery/jquery-migrate#readme
…rate

Move to the latest stable jQuery (3.7.1) and jQuery UI (1.14.1), replacing outdated 1.9.1 versions. This continues our incremental modernization path.

Update jQuery Migrate to 3.4.1 to match, ensuring accurate deprecation warnings during development. The new Migrate version supports the latest APIs and provides better debugging feedback.

All existing behavior is preserved. Warnings in the console should now reflect any remaining legacy patterns that need cleanup.

Part of the migration sequence:
- Previous: refactor .bind()/.click() → .on()
- This: upgrade core libraries
- Next: remove Migrate once clean
Update the search input's  binding to use  instead of the deprecated shorthand , aligning with our consistent event binding pattern.

This change keeps the codebase uniform with recent refactors (e.g., click, focus, keydown) and prepares for safe compatibility with jQuery 3.x now that we've upgraded.

No behavioral changes event logic and timing remain identical.

Part of ongoing effort to eliminate legacy jQuery patterns ahead of removing jQuery Migrate.
Remove jQuery Migrate 3.4.1 as it is no longer needed. The codebase has been fully updated to use modern jQuery patterns (e.g., .on() instead of .bind()), and no deprecation warnings have appeared in the console.

This marks the completion of our migration:
1. Added Migrate to detect issues
2. Refactored legacy event bindings
3. Upgraded to jQuery 3.7.1
4. Removed Migrate — now
Clean up obsolete  comments in application.js that referenced old, externally loaded jQuery files:
- //= require jquery-1.7.1.min
- //= require jquery-ui-1.8.18.custom.min

These files are no longer part of the asset pipeline and are instead loaded directly via CDN in the layout. Leaving these directives was misleading and could cause confusion for future contributors.

This change aligns the comments with the current architecture: jQuery is now a standalone dependency (3.7.1 via CDN), not a compiled asset.

No functional impact — this is purely a documentation and hygiene improvement.
@RafaelJohn9 RafaelJohn9 force-pushed the refactor/update/jquery branch from 76644af to 79b6413 Compare September 5, 2025 08:22
@RafaelJohn9 RafaelJohn9 requested a review from dscho September 5, 2025 08:23
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commits are now in a great shape!

dscho added a commit to dscho/git-scm.com that referenced this pull request Sep 5, 2025
This branch comes from git#2022.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho merged commit f847b39 into git:gh-pages Sep 5, 2025
1 check passed
@To1ne
Copy link
Collaborator

To1ne commented Sep 6, 2025

@RafaelJohn9 @dscho Awesome job! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update woefully outdated jQuery

3 participants