Open gregtyler opened 3 years ago
If this is going to take some time (it doesn't sound trivial) then in the meantime it would be nice to make the dependency on jQuery explicit. (I can't see it mentioned in the docs or the package.json)
Good point @DanCorder, we should add it to the installing with NPM documentation.
Edit: this has now been added in #187
GDS are considering removing jQuery from the prototype kit, which would mean that (until we remove jQuery ourselves) we'd need to bundle jQuery in the package and add it to the extension config file.
Does this need adding to the package.json
file until the dependency is removed? I tried removing jQuery per https://github.com/ministryofjustice/hmpps-template-typescript/pull/303/commits/eec17bba26095971c9dd3c352115b9fd238283e9 but then found that the sortable tables from this repo need it
jQuery is listed as a peer dependency in package.json
so, from what I understand of peer dependencies, your package manager should either auto-install it (this is what npm
seems to do) or warn you to install it manually.
your package manager should either auto-install it (this is what
npm
seems to do) or warn you to install it manually.
As far as I can tell it didn't do that. npm install
output after removing it as a direct dependency on our app but retaining the @ministryofjustice/frontend
dependency:
up to date, audited 1177 packages in 785ms
191 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Summary
It would be nice to eliminate our dependency on jQuery, instead using native browser functionality (e.g.
setAttribute
instead ofattr
,querySelector
rather thanfind
).Motivation
There are a few reasons I think this is beneficial:
Describe alternatives you've considered
We can just keep using jQuery and accept the concerns above for now.
Additional context
We'll need to add polyfills for functionality that isn't available in all browsers > IE8. (e.g. Opera Mini and IE9/10 don't support
HTMLElement.dataset
) We may be able to detect and polyfill automatically as part of the build process.We may also need to bulk out the IE8 polyfill if that's not already done by the GOV.UK Design system polyfill.
We shouldn't attempt this without unit tests (#132) as it would be difficult to spot regressions.