GNU bug report logs - #69132
[ELPA] Remove jQuery from elpa.gnu.org

Previous Next

Package: emacs;

Reported by: Philip Kaludercic <philipk <at> posteo.net>

Date: Wed, 14 Feb 2024 19:43:01 UTC

Severity: normal

Done: Philip Kaludercic <philipk <at> posteo.net>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 69132 <at> debbugs.gnu.org (full text, mbox):

From: Philip Kaludercic <philipk <at> posteo.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 69132 <at> debbugs.gnu.org
Subject: Re: bug#69132: [ELPA] Remove jQuery from elpa.gnu.org
Date: Thu, 15 Feb 2024 11:07:59 +0000
[Message part 1 (text/plain, inline)]
Philip Kaludercic <philipk <at> posteo.net> writes:

> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>>> I was recently surprised to see that elpa.gnu.org uses a jQuery library,
>>> where it really isn't necessary.  Re-implementing the same functionality
>>> can be done in a few more lines of plain Javascript, without the need
>>> for any minified code.  Tested with relatively recent versions of
>>> Firefox and Chromium, so perhaps it would be nice if someone with an
>>> older browser could check if I didn't make any bold assumptions. 
>>
>> Works for me, but I'm not using an "older browser" 🙁
>
> I have a few older machines that I could try it out on.
>
>>> diff --git a/html/javascript/package-search.js b/html/javascript/package-search.js
>>> index 47134045eb..92f29703a3 100644
>>> --- a/html/javascript/package-search.js
>>> +++ b/html/javascript/package-search.js
>>> @@ -1,6 +1,35 @@
>>> -$(document).ready(function() {
>>> -	$('table').filterTable({
>>> -		label: '',
>>> -		placeholder: 'Search packages...'
>>> -	});
>>> +window.addEventListener("load", function (event) {
>>> +	const table = document.getElementById("packages");
>>> +
>>> +	const search = document.createElement("input");
>>> +	search.setAttribute("placeholder", "Search packages...");
>>> +	search.setAttribute("type", "search");
>> [...]
>>
>> I know very little about Javascript, but I'm curious: can't we add the
>> `input` element directly in the HTML file, and skip those first 4 lines or so?
>
> Of course, I just replicated what the jquery plugin did.  I suppose the
> idea was to not have a broken search field labelled "Search
> packages...", if there is no Javascript to make it work in the first
> place.
>
>>> diff --git a/html/layout.css b/html/layout.css
>>> index 4f5c50d393..434220f8c1 100644
>>> --- a/html/layout.css
>>> +++ b/html/layout.css
>>
>> A rationale/description of this part of the change would be welcome.
>>
>>> From 73a9335634f54b71e9723047f327cf782cfb7244 Mon Sep 17 00:00:00 2001
>>> From: Philip Kaludercic <philipk <at> posteo.net>
>>> Date: Wed, 14 Feb 2024 20:37:37 +0100
>>> Subject: [PATCH] Update HTML generation for new filter implementation
>>>
>>> ---
>>>  elpa-admin.el | 27 +++++++++++----------------
>>>  1 file changed, 11 insertions(+), 16 deletions(-)
>>
>> Same here.
>
> The idea is just to not use CSS classes to pinpoint specific Elements in
> the DOM.  That is what IDs are for (ideally the "ID -> elements" map
> should be injective).  I needed that to use document.getElementById in
> the new script.
>
> Should I update the commit messages to explain the change?

I have updated patches with a few more cases that I had initially
forgotten and split the one for the main branch into two:



[0001-Generate-HTML5-tags-instead-of-div-s-with-custom-cla.patch (text/x-patch, attachment)]
[0001-Use-more-HTML5-tags-instead-of-custom-CSS-classes.patch (text/x-patch, attachment)]
[0002-Replace-jQuery-filtertable-script-with-plain-Javascr.patch (text/x-patch, attachment)]

This bug report was last modified 1 year and 87 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.