Thread: Download navigation UX
Hi
The attached patch is a first cut at part of a larger task that Jonathan and I have been discussing to improve the UX and simplify the download flow on the website.
This patch updates the main download page (/download) in a number of ways:
- Wording at the top and in the left menu is simplified, moving away from "words for the sake of it" as we have now and using more common and easy to understand terms like "Packages" instead of "Binaries"
- Some images have been updated or replaced to ensure they all have transparent backgrounds.
- The indented list of binary options with its myriad of links is replaced with a set of highly visible buttons to choose your distro family - see the attached initial.png - and then the distribution where applicable:
- The BSD and Linux buttons will display a second set of buttons to choose the distro when clicked. See linux.png.
- If Javascript is disabled;
- The BSD button will navigate to a new page showing the buttons for each supported BSD distro.
- The Linux button will navigate to the existing generic Linux page, where the list of distros at the top has also been replaced with buttons.
This patch does not attempt to sanitise the rest of the download index or any of the sub-pages at this time. That'll come later.
--
Comments/bikeshedding?
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment
Following a chat with Vik, here's an updated patch which fixes a couple of minor issues and greys the background of the selected OS when clicked.
I plan to commit tomorrow if there are no objections.
On Wed, Jul 1, 2020 at 1:23 PM Dave Page <dpage@pgadmin.org> wrote:
HiThe attached patch is a first cut at part of a larger task that Jonathan and I have been discussing to improve the UX and simplify the download flow on the website.This patch updates the main download page (/download) in a number of ways:- Wording at the top and in the left menu is simplified, moving away from "words for the sake of it" as we have now and using more common and easy to understand terms like "Packages" instead of "Binaries"- Some images have been updated or replaced to ensure they all have transparent backgrounds.- The indented list of binary options with its myriad of links is replaced with a set of highly visible buttons to choose your distro family - see the attached initial.png - and then the distribution where applicable:- The BSD and Linux buttons will display a second set of buttons to choose the distro when clicked. See linux.png.- If Javascript is disabled;- The BSD button will navigate to a new page showing the buttons for each supported BSD distro.- The Linux button will navigate to the existing generic Linux page, where the list of distros at the top has also been replaced with buttons.This patch does not attempt to sanitise the rest of the download index or any of the sub-pages at this time. That'll come later.Comments/bikeshedding?--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment
On 7/6/20 6:59 AM, Dave Page wrote: > Following a chat with Vik, here's an updated patch which fixes a couple > of minor issues and greys the background of the selected OS when clicked. > > I plan to commit tomorrow if there are no objections. I was out all last week, however I will review today :) Jonathan
Attachment
On 7/6/20 8:34 AM, Jonathan S. Katz wrote: > On 7/6/20 6:59 AM, Dave Page wrote: >> Following a chat with Vik, here's an updated patch which fixes a couple >> of minor issues and greys the background of the selected OS when clicked. >> >> I plan to commit tomorrow if there are no objections. > > I was out all last week, however I will review today :) Reviewed. Per some offline conversation as well as online review, please see v3 of the attached patch. Notable changes: - Renamed some IDs/classes to match the current pattern. Removed / consolidated some of the CSS - Moved the JavaScript into the main JS file - A few formatting changes for readability General comments: - There is a use of "!important" in the anchor tag text that I'm not that happy about, but starting to dig into it, there is a global !important that's causing it to be that way. I didn't have time to fully dig into it, but noting for future improvements. - I did look at it on mobile/tablet view and it seems like it "meets the standards" that the search engines look for, knowing that even if things are moving more "mobile first", it's not like people are doing to download PostgreSQL to their mobile device from a web browser (but happy to be corrected there). Anyway, looks good! Thanks, Jonathan
Attachment
On Mon, Jul 6, 2020 at 4:17 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:
On 7/6/20 8:34 AM, Jonathan S. Katz wrote:
> On 7/6/20 6:59 AM, Dave Page wrote:
>> Following a chat with Vik, here's an updated patch which fixes a couple
>> of minor issues and greys the background of the selected OS when clicked.
>>
>> I plan to commit tomorrow if there are no objections.
>
> I was out all last week, however I will review today :)
Reviewed. Per some offline conversation as well as online review, please
see v3 of the attached patch. Notable changes:
- Renamed some IDs/classes to match the current pattern. Removed /
consolidated some of the CSS
- Moved the JavaScript into the main JS file
- A few formatting changes for readability
General comments:
- There is a use of "!important" in the anchor tag text that I'm not
that happy about, but starting to dig into it, there is a global
!important that's causing it to be that way. I didn't have time to fully
dig into it, but noting for future improvements.
- I did look at it on mobile/tablet view and it seems like it "meets the
standards" that the search engines look for, knowing that even if things
are moving more "mobile first", it's not like people are doing to
download PostgreSQL to their mobile device from a web browser (but happy
to be corrected there).
Anyway, looks good!
We should really avoid those inline event handlers, as they will (I think) break our CSP.
I notice that some of those snuck in again in the copy-urls-to-clipboard patch of recent, and that should be fixed again. But before that we put in some work to try to avoid those, let's try not to break that. E.g. for the download pages, specifically in 1d78793add2c65545f7f37dbd75ab7decc399cea.
On Mon, Jul 6, 2020 at 3:25 PM Magnus Hagander <magnus@hagander.net> wrote:
On Mon, Jul 6, 2020 at 4:17 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:On 7/6/20 8:34 AM, Jonathan S. Katz wrote:
> On 7/6/20 6:59 AM, Dave Page wrote:
>> Following a chat with Vik, here's an updated patch which fixes a couple
>> of minor issues and greys the background of the selected OS when clicked.
>>
>> I plan to commit tomorrow if there are no objections.
>
> I was out all last week, however I will review today :)
Reviewed. Per some offline conversation as well as online review, please
see v3 of the attached patch. Notable changes:
- Renamed some IDs/classes to match the current pattern. Removed /
consolidated some of the CSS
- Moved the JavaScript into the main JS file
- A few formatting changes for readability
General comments:
- There is a use of "!important" in the anchor tag text that I'm not
that happy about, but starting to dig into it, there is a global
!important that's causing it to be that way. I didn't have time to fully
dig into it, but noting for future improvements.
- I did look at it on mobile/tablet view and it seems like it "meets the
standards" that the search engines look for, knowing that even if things
are moving more "mobile first", it's not like people are doing to
download PostgreSQL to their mobile device from a web browser (but happy
to be corrected there).
Anyway, looks good!We should really avoid those inline event handlers, as they will (I think) break our CSP.
Hmm, yeah - so they do.
I notice that some of those snuck in again in the copy-urls-to-clipboard patch of recent, and that should be fixed again. But before that we put in some work to try to avoid those, let's try not to break that. E.g. for the download pages, specifically in 1d78793add2c65545f7f37dbd75ab7decc399cea.
Something like the attached?
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment
Here's an updated patch (based on Jonathan's update) which combines the inline handler patch and removes the inline handlers from the main patch.
On Mon, Jul 6, 2020 at 5:25 PM Dave Page <dpage@pgadmin.org> wrote:
On Mon, Jul 6, 2020 at 3:25 PM Magnus Hagander <magnus@hagander.net> wrote:On Mon, Jul 6, 2020 at 4:17 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:On 7/6/20 8:34 AM, Jonathan S. Katz wrote:
> On 7/6/20 6:59 AM, Dave Page wrote:
>> Following a chat with Vik, here's an updated patch which fixes a couple
>> of minor issues and greys the background of the selected OS when clicked.
>>
>> I plan to commit tomorrow if there are no objections.
>
> I was out all last week, however I will review today :)
Reviewed. Per some offline conversation as well as online review, please
see v3 of the attached patch. Notable changes:
- Renamed some IDs/classes to match the current pattern. Removed /
consolidated some of the CSS
- Moved the JavaScript into the main JS file
- A few formatting changes for readability
General comments:
- There is a use of "!important" in the anchor tag text that I'm not
that happy about, but starting to dig into it, there is a global
!important that's causing it to be that way. I didn't have time to fully
dig into it, but noting for future improvements.
- I did look at it on mobile/tablet view and it seems like it "meets the
standards" that the search engines look for, knowing that even if things
are moving more "mobile first", it's not like people are doing to
download PostgreSQL to their mobile device from a web browser (but happy
to be corrected there).
Anyway, looks good!We should really avoid those inline event handlers, as they will (I think) break our CSP.Hmm, yeah - so they do.I notice that some of those snuck in again in the copy-urls-to-clipboard patch of recent, and that should be fixed again. But before that we put in some work to try to avoid those, let's try not to break that. E.g. for the download pages, specifically in 1d78793add2c65545f7f37dbd75ab7decc399cea.Something like the attached?--Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment
On 7/7/20 6:02 AM, Dave Page wrote: > Here's an updated patch (based on Jonathan's update) which combines the > inline handler patch and removes the inline handlers from the main patch. Looking good. One comment: Given there's nothing dynamic about serving the new apt.js / download.js, we don't need to serve those dynamically from the Django app. We can just plop them into "/media/js", e.g. "/media/js/download.js" and then this becomes: <script type="text/javascript" src="/media/js/download.js?{{gitrev}}"></script> Thanks, Jonathan
Attachment
On Tue, Jul 7, 2020 at 3:15 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:
On 7/7/20 6:02 AM, Dave Page wrote:
> Here's an updated patch (based on Jonathan's update) which combines the
> inline handler patch and removes the inline handlers from the main patch.
Looking good. One comment:
Given there's nothing dynamic about serving the new apt.js /
download.js, we don't need to serve those dynamically from the Django
app. We can just plop them into "/media/js", e.g.
"/media/js/download.js" and then this becomes:
<script type="text/javascript"
src="/media/js/download.js?{{gitrev}}"></script>
+1. And we already have a download.js there, so we should probably reuse that.
Which brings up my other point, which is let's try to make this one js and not two -- will make browser caching a lot more effective, and it's not like either of these is big enough to have ay substantial effect on download sizes (in fact, making two separate requests probably makes the downloading significantly bigger)
On Tue, Jul 7, 2020 at 3:18 PM Magnus Hagander <magnus@hagander.net> wrote:
On Tue, Jul 7, 2020 at 3:15 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:On 7/7/20 6:02 AM, Dave Page wrote:
> Here's an updated patch (based on Jonathan's update) which combines the
> inline handler patch and removes the inline handlers from the main patch.
Looking good. One comment:
Given there's nothing dynamic about serving the new apt.js /
download.js, we don't need to serve those dynamically from the Django
app. We can just plop them into "/media/js", e.g.
"/media/js/download.js" and then this becomes:
<script type="text/javascript"
src="/media/js/download.js?{{gitrev}}"></script>+1. And we already have a download.js there, so we should probably reuse that.
Nevermind, we don't. That was leftover in my directory from testing a previous one of your patches :) Which Jonathan fixed (for the same reason) by moving it into main.js
On Tue, Jul 7, 2020 at 2:15 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:
On 7/7/20 6:02 AM, Dave Page wrote:
> Here's an updated patch (based on Jonathan's update) which combines the
> inline handler patch and removes the inline handlers from the main patch.
Looking good. One comment:
Given there's nothing dynamic about serving the new apt.js /
download.js, we don't need to serve those dynamically from the Django
app. We can just plop them into "/media/js", e.g.
"/media/js/download.js" and then this becomes:
<script type="text/javascript"
src="/media/js/download.js?{{gitrev}}"></script>
Thanks - committed with that change.
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On 7/7/20 11:53 AM, Dave Page wrote: > > > On Tue, Jul 7, 2020 at 2:15 PM Jonathan S. Katz <jkatz@postgresql.org > <mailto:jkatz@postgresql.org>> wrote: > > On 7/7/20 6:02 AM, Dave Page wrote: > > Here's an updated patch (based on Jonathan's update) which > combines the > > inline handler patch and removes the inline handlers from the main > patch. > > Looking good. One comment: > > Given there's nothing dynamic about serving the new apt.js / > download.js, we don't need to serve those dynamically from the Django > app. We can just plop them into "/media/js", e.g. > "/media/js/download.js" and then this becomes: > > <script type="text/javascript" > src="/media/js/download.js?{{gitrev}}"></script> > > > Thanks - committed with that change. Awesome, thanks! Jonathan
Attachment
On Tue, Jul 7, 2020 at 5:54 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:
On 7/7/20 11:53 AM, Dave Page wrote:
>
>
> On Tue, Jul 7, 2020 at 2:15 PM Jonathan S. Katz <jkatz@postgresql.org
> <mailto:jkatz@postgresql.org>> wrote:
>
> On 7/7/20 6:02 AM, Dave Page wrote:
> > Here's an updated patch (based on Jonathan's update) which
> combines the
> > inline handler patch and removes the inline handlers from the main
> patch.
>
> Looking good. One comment:
>
> Given there's nothing dynamic about serving the new apt.js /
> download.js, we don't need to serve those dynamically from the Django
> app. We can just plop them into "/media/js", e.g.
> "/media/js/download.js" and then this becomes:
>
> <script type="text/javascript"
> src="/media/js/download.js?{{gitrev}}"></script>
>
>
> Thanks - committed with that change.
Awesome, thanks!
I still stand by my review comment that it shouldn't be multiple JS files for such trivial things.
On 2020-Jul-07, Dave Page wrote: > Thanks - committed with that change. Cool stuff, thanks, looks good! So now we can discuss the addition of 2ndQuadrant and PostgresPro installers there, aye? -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On Tue, Jul 7, 2020 at 7:22 PM Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
On 2020-Jul-07, Dave Page wrote:
> Thanks - committed with that change.
Cool stuff, thanks, looks good!
So now we can discuss the addition of 2ndQuadrant and PostgresPro
installers there, aye?
If you mean getting third party installers off the main download page and moved into the software catalogue, then yes, of course :)
On 2020-Jul-07, Magnus Hagander wrote: > If you mean getting third party installers off the main download page and > moved into the software catalogue, then yes, of course :) Well, I meant this patch https://postgr.es/m/CAH+GA0pUz26AoyF+LazhPS02HwuBO+kPZ2wcRcOwq9u+cPPOag@mail.gmail.com which apparently has been waiting for this restructuring for years. (Oleg said there's a PostgresPro patch somewhere too, but I don't know where that is.) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On Tue, Jul 7, 2020 at 7:50 PM Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
On 2020-Jul-07, Magnus Hagander wrote:
> If you mean getting third party installers off the main download page and
> moved into the software catalogue, then yes, of course :)
Well, I meant this patch
https://postgr.es/m/CAH+GA0pUz26AoyF+LazhPS02HwuBO+kPZ2wcRcOwq9u+cPPOag@mail.gmail.com
which apparently has been waiting for this restructuring for years.
(Oleg said there's a PostgresPro patch somewhere too, but I don't know
where that is.)
There have been many threads and hundreds, if not thousands, of emails on the subject over the past years.
My recollection is that the latest conclusion was exactly that -- stop listing third party installers as part of the main download pages, put them in the software catalogue, and put a proper link to the software catalogue from the download pages.
And no, I don't remember exactly when that conclusion was reached.
//Magnus
On Tue, Jul 7, 2020 at 6:22 PM Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
On 2020-Jul-07, Dave Page wrote:
> Thanks - committed with that change.
Cool stuff, thanks, looks good!
Thanks!
So now we can discuss the addition of 2ndQuadrant and PostgresPro
installers there, aye?
I'll be honest (at risk of starting a flamewar)... on a personal level, I really do not want to do that, and I don't think we should.
First though, I want to make it clear that this has nothing to do with the fact that the EDB installers are the ones that are there at the moment, though obviously I do have a vested interest in them.
The reasons I don't think we should do this are:
* PostgreSQL is often seen as complicated and difficult to use - and we know from experience that part of that is knowing what to install and how to install it. Part of my focus at the moment is simplifying that process. So far:
- I've tweaked the generation of installation scripts for RPMs and DEBs so that it's easy to copy/paste the exact commands required
- The commit in this thread makes it much easier to navigate the download pages
- The yum.postgresql.org and zypp.postgresql.org sites have been overhauled by Devrim and I to make them much more readable and up to date.
- I'm currently working on integrated APT and YUM package browsing on the website to make it much easier to see what's available in those repos.
Planned work includes:
- Either Vik or I will soon update the SUSE page to match the way the Red Hat one works.
- Simplifying and minimising the text on the download pages to make it easier for users to understand, particularly non-native English speakers.
- Considering moving third party packages and less-oft used options to sub-pages to de-clutter the main download pages (this is why I'm currently counting outbound link clicks, so we can make informed decisions).
By adding additional installer options to the pages, we complicate and confuse things for users. Why should they choose one installer over another? How do we explain the subtle or even virtually non-existent differences without adding a lot more reading material? Which should come first and so on?
* By offering multiple installers for the same platform we add confusion and the very real possibility for users to break their systems during upgrades if they're not full aware of the differences, e.g.
- What happens if someone tries to upgrade an existing installation of one installer with one from another vendor?
- What happens when a user tries to migrate their Python based application from (for example) the EDB installer which may support Python 3.7 through it's language pack add-on to the 2ndQuadrant installer which is built against Python 2.7 from ActiveState (that's a made up example, but you get the point).
- What happens when a user tries to upgrade from one installer to another, and it seems to work until they realise the new installer doesn't have the pldebugger extension that they need?
- What happens when the user switches to another installer, only to find that there is a difference in the toolchain version, so their app that was compiled with VC++ 2017 suddenly starts crashing because they're now using a libpq built with VC++ 2019?
- When users are asking for support on the mailing lists, the knowledge in the community will become diluted as different users will have experience with different installers.
- How many first responses to each thread are going to become "which installer are you using" followed by "oh, sorry - I only know the XXXX installers"?
- Can users be sure that addons like PostGIS are built in a way that is compatible with any of the installer options available?
In short, having multiple installer options will inevitably lead to a significantly more complex experience on the website, potential for users to break their systems if they upgrade or switch to a different installer (inadvertently or intentionally), and make it harder to support those users.
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Tue, Jul 7, 2020 at 4:55 PM Magnus Hagander <magnus@hagander.net> wrote:
On Tue, Jul 7, 2020 at 5:54 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:On 7/7/20 11:53 AM, Dave Page wrote:
>
>
> On Tue, Jul 7, 2020 at 2:15 PM Jonathan S. Katz <jkatz@postgresql.org
> <mailto:jkatz@postgresql.org>> wrote:
>
> On 7/7/20 6:02 AM, Dave Page wrote:
> > Here's an updated patch (based on Jonathan's update) which
> combines the
> > inline handler patch and removes the inline handlers from the main
> patch.
>
> Looking good. One comment:
>
> Given there's nothing dynamic about serving the new apt.js /
> download.js, we don't need to serve those dynamically from the Django
> app. We can just plop them into "/media/js", e.g.
> "/media/js/download.js" and then this becomes:
>
> <script type="text/javascript"
> src="/media/js/download.js?{{gitrev}}"></script>
>
>
> Thanks - committed with that change.
Awesome, thanks!I still stand by my review comment that it shouldn't be multiple JS files for such trivial things.
Hmm, for some reason this and a number of your other messages went into spam. I wonder what Google is trying to tell me?
They're in separate files because they are setting up event handlers specific to each page. I don't know of a way to do that with a shared file without jumping through some likely hacky and fragile hoops to allow the code to figure out what page it's been called from - i.e. making sure that certain DOM IDs are always unique across any pages the shared file is called from, and testing for the existence of those IDs to figure out what event handlers to setup at runtime.
Having the separate files is certainly an extra download and slightly less cacheable (for a few bytes of code), but I think that's outweighed by the additional complexity and code that having a single file would require.
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Wed, Jul 8, 2020 at 1:03 PM Dave Page <dpage@pgadmin.org> wrote:
On Tue, Jul 7, 2020 at 4:55 PM Magnus Hagander <magnus@hagander.net> wrote:On Tue, Jul 7, 2020 at 5:54 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:On 7/7/20 11:53 AM, Dave Page wrote:
>
>
> On Tue, Jul 7, 2020 at 2:15 PM Jonathan S. Katz <jkatz@postgresql.org
> <mailto:jkatz@postgresql.org>> wrote:
>
> On 7/7/20 6:02 AM, Dave Page wrote:
> > Here's an updated patch (based on Jonathan's update) which
> combines the
> > inline handler patch and removes the inline handlers from the main
> patch.
>
> Looking good. One comment:
>
> Given there's nothing dynamic about serving the new apt.js /
> download.js, we don't need to serve those dynamically from the Django
> app. We can just plop them into "/media/js", e.g.
> "/media/js/download.js" and then this becomes:
>
> <script type="text/javascript"
> src="/media/js/download.js?{{gitrev}}"></script>
>
>
> Thanks - committed with that change.
Awesome, thanks!I still stand by my review comment that it shouldn't be multiple JS files for such trivial things.Hmm, for some reason this and a number of your other messages went into spam. I wonder what Google is trying to tell me?
Probably something far too close to the truth.. :)
They're in separate files because they are setting up event handlers specific to each page. I don't know of a way to do that with a shared file without jumping through some likely hacky and fragile hoops to allow the code to figure out what page it's been called from - i.e. making sure that certain DOM IDs are always unique across any pages the shared file is called from, and testing for the existence of those IDs to figure out what event handlers to setup at runtime.
We already do similar in forms.js, though I have to admit a lot less than I thought we were. I guess I'm getting it slightly confused with other repos. We *already* have the requirement to keep "certain DOM Ids" unique -- we use it for CSS. And I really don't see that as any bigger problem than keeping the filename of the JS file unique.
Having the separate files is certainly an extra download and slightly less cacheable (for a few bytes of code), but I think that's outweighed by the additional complexity and code that having a single file would require.
It's really more the latency than anything else. I'm pretty strongly on the side of thinking the cost of that is higher than the small amount of complexity -- I really don't think it would be much. But no, I'm not strongly *enough* on that side to actually try to produce proper metrics to prove it :)
On Wed, Jul 8, 2020 at 4:16 PM Magnus Hagander <magnus@hagander.net> wrote:
They're in separate files because they are setting up event handlers specific to each page. I don't know of a way to do that with a shared file without jumping through some likely hacky and fragile hoops to allow the code to figure out what page it's been called from - i.e. making sure that certain DOM IDs are always unique across any pages the shared file is called from, and testing for the existence of those IDs to figure out what event handlers to setup at runtime.We already do similar in forms.js, though I have to admit a lot less than I thought we were. I guess I'm getting it slightly confused with other repos.
That's a *lot* more generic though from what I can see.
We *already* have the requirement to keep "certain DOM Ids" unique -- we use it for CSS. And I really don't see that as any bigger problem than keeping the filename of the JS file unique.
Do you have an example? I can't see any obvious ones. Ideally we should be using classes for CSS imho, rather than IDs anyway imho (and we really shouldn't be using IDs in a way that requires them to be unique across pages that may well be unknown to the casual hacker - that would be a real maintenance headache).
Having the separate files is certainly an extra download and slightly less cacheable (for a few bytes of code), but I think that's outweighed by the additional complexity and code that having a single file would require.It's really more the latency than anything else. I'm pretty strongly on the side of thinking the cost of that is higher than the small amount of complexity -- I really don't think it would be much. But no, I'm not strongly *enough* on that side to actually try to produce proper metrics to prove it :)
The code complexity isn't that much I grant you. We'd have to wrap something like the following around each event listener setup:
var elem = document.getElementById("elementID");
if (elem) {
// setup listener
}
However the cognitive complexity for the maintainer/developer of ensuring IDs are unique across different pages is *much* higher.
On Wed, Jul 8, 2020 at 5:56 PM Dave Page <dpage@pgadmin.org> wrote:
On Wed, Jul 8, 2020 at 4:16 PM Magnus Hagander <magnus@hagander.net> wrote:They're in separate files because they are setting up event handlers specific to each page. I don't know of a way to do that with a shared file without jumping through some likely hacky and fragile hoops to allow the code to figure out what page it's been called from - i.e. making sure that certain DOM IDs are always unique across any pages the shared file is called from, and testing for the existence of those IDs to figure out what event handlers to setup at runtime.We already do similar in forms.js, though I have to admit a lot less than I thought we were. I guess I'm getting it slightly confused with other repos.That's a *lot* more generic though from what I can see.
Yea.
We *already* have the requirement to keep "certain DOM Ids" unique -- we use it for CSS. And I really don't see that as any bigger problem than keeping the filename of the JS file unique.Do you have an example? I can't see any obvious ones. Ideally we should be using classes for CSS imho, rather than IDs anyway imho (and we really shouldn't be using IDs in a way that requires them to be unique across pages that may well be unknown to the casual hacker - that would be a real maintenance headache).
Hmm. Looking at it it's fewer than I thought, because we have tons of CSS rules that aren't actually in use. But if you want a recent example, release-notes. And the navigation.
What would be the reason to use classes for things that are only supposed to appear once? I thought the entire point of classes vs ids in the rules are classes for things that there can be more than one of, id when it's a unique identifier.
Having the separate files is certainly an extra download and slightly less cacheable (for a few bytes of code), but I think that's outweighed by the additional complexity and code that having a single file would require.It's really more the latency than anything else. I'm pretty strongly on the side of thinking the cost of that is higher than the small amount of complexity -- I really don't think it would be much. But no, I'm not strongly *enough* on that side to actually try to produce proper metrics to prove it :)The code complexity isn't that much I grant you. We'd have to wrap something like the following around each event listener setup:var elem = document.getElementById("elementID");if (elem) {// setup listener
}
Yeah, or the same for classnames if that makes you happier :)
I don't really consider that very complex. We already inject jquery on all pages, so you could use that to simplify it even more. But I would suggest not doing that -- it would be nice to at some point be able to remove jquery as a dependency, so iet's not dig that hole deeper.
However the cognitive complexity for the maintainer/developer of ensuring IDs are unique across different pages is *much* higher.
I still don't see how those are very high. What's the likelihood of using an id like "yumdownloads" (or similar) on a page that is unrelated to yum? I'd say that's pretty much zero.
On 7/8/20 1:04 PM, Magnus Hagander wrote: > > > On Wed, Jul 8, 2020 at 5:56 PM Dave Page <dpage@pgadmin.org > <mailto:dpage@pgadmin.org>> wrote: > > > > On Wed, Jul 8, 2020 at 4:16 PM Magnus Hagander <magnus@hagander.net > <mailto:magnus@hagander.net>> wrote: > > We *already* have the requirement to keep "certain DOM Ids" > unique -- we use it for CSS. And I really don't see that as any > bigger problem than keeping the filename of the JS file unique > Do you have an example? I can't see any obvious ones. Ideally we > should be using classes for CSS imho, rather than IDs anyway imho > (and we really shouldn't be using IDs in a way that requires them to > be unique across pages that may well be unknown to the casual hacker > - that would be a real maintenance headache). > > Hmm. Looking at it it's fewer than I thought, because we have tons of > CSS rules that aren't actually in use. But if you want a recent example, > release-notes. And the navigation. Some of this was done as part of the "great style conversion of 2018" to try to keep things from breaking too much. The other major one is in our documentation, to keep the documentation styles separate from the main site styles. > What would be the reason to use classes for things that are only > supposed to appear once? I thought the entire point of classes vs ids in > the rules are classes for things that there can be more than one of, id > when it's a unique identifier. The trend I've seen in web development is that classes are used to invoke style, while IDs are used to invoice anchors, or to "namespace" a set of styles. I've seen this a lot in documentation. In other words, pretty much anything involved with styling is using a class. It is what it is. > Having the separate files is certainly an extra download and > slightly less cacheable (for a few bytes of code), but I > think that's outweighed by the additional complexity and > code that having a single file would require. > > > It's really more the latency than anything else. I'm pretty > strongly on the side of thinking the cost of that is higher than > the small amount of complexity -- I really don't think it would > be much. But no, I'm not strongly *enough* on that side to > actually try to produce proper metrics to prove it :) > > > The code complexity isn't that much I grant you. We'd have to wrap > something like the following around each event listener setup: > > var elem = document.getElementById("elementID"); > if (elem) { > // setup listener > > } > > > Yeah, or the same for classnames if that makes you happier :) From a maintenance perspective, I'd vote for "less files" and just clearly comment what each JS block is doing in the one file. I think it's fairly simple to gate the event listeners. And if it's a pattern we're using a lot, we can write a helper function to do so ;) > I don't really consider that very complex. We already inject jquery on > all pages, so you could use that to simplify it even more. But I would > suggest not doing that -- it would be nice to at some point be able to > remove jquery as a dependency, so iet's not dig that hole deeper. I'm ok with this. The other pattern I've seen in web development is more things going native JavaScript (particularly because what's supported in browsers is way more sophisticated now), sometimes coupled with "transpilers" or the like, or using a framework. > However the cognitive complexity for the maintainer/developer of > ensuring IDs are unique across different pages is *much* higher. > > I still don't see how those are very high. What's the likelihood of > using an id like "yumdownloads" (or similar) on a page that is unrelated > to yum? I'd say that's pretty much zero. Yeah, I think the probability of this being an issue is low. Jonathan
Attachment
On Wed, Jul 8, 2020 at 7:17 PM Jonathan S. Katz <jkatz@postgresql.org> wrote:
> However the cognitive complexity for the maintainer/developer of
> ensuring IDs are unique across different pages is *much* higher.
>
> I still don't see how those are very high. What's the likelihood of
> using an id like "yumdownloads" (or similar) on a page that is unrelated
> to yum? I'd say that's pretty much zero.
Yeah, I think the probability of this being an issue is low.
For the record, I still strongly disagree that this is a sensible practice. It may not be a big issue in a relatively self-contained example such as this one, but it easily could be in other areas.
That said, changed and pushed.