Skip to content

Commit f847b39

Browse files
authored
Upgrade from woefully outdated jQuery version (#2022)
## Changes <!-- List the changes this PR makes. --> - fix #2004 ## Context <!-- Explain why you're making these changes. --> 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: - [x] **Improve compatibility** with current and future browser standards - [x] **Leverage bug fixes and performance improvements** from jQuery 3.x - [x] **Enable use of modern jQuery features** (e.g. improved `.on()`, better event delegation) - [x] **Support upcoming enhancements** that depend on reliable, up-to-date tooling - [x] **Remove reliance on deprecated APIs** that hinder maintainability - [x] **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.
2 parents 80312b3 + 79b6413 commit f847b39

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

assets/js/application.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
1111
// about supported directives.
1212
//
13-
//= require jquery-1.7.1.min
14-
//= require jquery-ui-1.8.18.custom.min
1513
//= require jquery.defaultvalue
1614
//= require session.min
1715

@@ -43,7 +41,7 @@ $(document).ready(function() {
4341

4442
function onPopState(fn) {
4543
if (window.history && window.history.pushState) {
46-
return $(window).bind('popstate', function(event) {
44+
return $(window).on('popstate', function() {
4745
var section;
4846
initialPop = !popped && location.href === initialURL;
4947
popped = true;
@@ -115,7 +113,7 @@ var GitTurns20 = {
115113
} else {
116114
let start = 0
117115
let count = 0
118-
$("#tagline").click(e => {
116+
$("#tagline").on('click', e => {
119117
if (count === 0 || e.timeStamp > start + count * 1000) {
120118
start = e.timeStamp;
121119
count = 1;
@@ -181,20 +179,20 @@ var Search = {
181179
},
182180

183181
observeFocus: function() {
184-
$('form#search input').focus(function() {
182+
$('form#search input').on('focus', function() {
185183
$(this).parent('form#search').switchClass("", "focus", 200);
186184
});
187-
$('form#search input').blur(function() {
185+
$('form#search input').on('blur', function() {
188186
Search.resetForm();
189187
});
190188
},
191189

192190
observeTextEntry: function() {
193-
$('form#search input').keyup(function(e) {
191+
$('form#search input').on('keyup', function() {
194192
Search.runSearch();
195193
});
196194

197-
$('form#search input').keydown(function(e) {
195+
$('form#search input').on('keydown', function(e) {
198196
if ($('#search-results').not(':visible') && e.which != 27) {
199197
$('#search-results').fadeIn(0.2);
200198
Search.highlight(Search.selectedIndex);
@@ -220,16 +218,16 @@ var Search = {
220218
},
221219

222220
observeResultsClicks: function() {
223-
$('#search-results').mousedown(function(e) {
221+
$('#search-results').on('mousedown', function(e) {
224222
e.preventDefault();
225223
});
226224
},
227225

228226
installKeyboardShortcuts: function() {
229-
$(document).keydown(function(e) {
227+
$(document).on('keydown', function(e) {
230228
if (e.target.tagName.toUpperCase() !== 'INPUT' && ['s', 'S', '/'].includes(e.key)) {
231229
e.preventDefault();
232-
$('form#search input').focus();
230+
$('form#search input').trigger('focus');
233231
}
234232
else if (e.target.tagName.toUpperCase() !== 'INPUT') GitTurns20.keydown(e);
235233
});
@@ -476,7 +474,7 @@ var Dropdowns = {
476474

477475
observeTriggers: function() {
478476
var eles = $('.dropdown-trigger');
479-
eles.click(function(e) {
477+
eles.on('click', function(e) {
480478
e.preventDefault();
481479

482480
$(this).toggleClass('active');
@@ -497,7 +495,7 @@ var Forms = {
497495
},
498496

499497
observeCopyableInputs: function() {
500-
$('input.copyable').click(function() {
498+
$('input.copyable').on('click', function() {
501499
$(this).select();
502500
});
503501
}
@@ -551,7 +549,7 @@ var Downloads = {
551549
},
552550

553551
observeGUIOSFilter: function() {
554-
$('a.gui-os-filter').click(function(e) {
552+
$('a.gui-os-filter').on('click', function(e) {
555553
e.preventDefault();
556554
var os = $(this).attr('data-os');
557555

@@ -654,7 +652,7 @@ var DarkMode = {
654652
}
655653
button.css("display", "block");
656654

657-
button.click(function(e) {
655+
button.on('click', function(e) {
658656
e.preventDefault();
659657
let theme
660658
if (prefersDarkScheme) {
@@ -786,12 +784,12 @@ var PostelizeAnchor = {
786784

787785
// Scroll to Top
788786
$('#scrollToTop').removeClass('no-js');
789-
$(window).scroll(function() {
787+
$(window).on('scroll', function() {
790788
$(this).scrollTop() > 150
791789
? $('#scrollToTop').fadeIn()
792790
: $('#scrollToTop').fadeOut();
793791
});
794-
$('#scrollToTop').click(function(e) {
792+
$('#scrollToTop').on('click', function(e) {
795793
e.preventDefault();
796794
$("html, body").animate({
797795
scrollTop: 0

layouts/partials/footer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<img src="{{ relURL "images/icons/[email protected]" }}" width="20" height="20" alt="scroll-to-top"/>
1212
</a>
1313

14-
<script src="{{ relURL "js/jquery-1.7.1.min.js" }}"></script>
15-
<script src="{{ relURL "js/jquery-ui-1.8.18.custom.min.js" }}"></script>
14+
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
15+
<script src="https://code.jquery.com/ui/1.14.1/jquery-ui.min.js"></script>
1616
<script src="{{ relURL "js/jquery.defaultvalue.js" }}"></script>
1717
<script src="{{ relURL "js/session.min.js" }}"></script>
1818
{{ $js := resources.Get "js/application.js" | resources.ExecuteAsTemplate "js/application.js" . | resources.Minify | fingerprint }}

0 commit comments

Comments
 (0)