govuk-design-system
govuk-design-system copied to clipboard
Increase the likelihood that service teams will only include the bits of the Design System they are using
Brief
Increase the likelihood that service teams will only include the bits of the Design System they are actually using in their service.
Our documentation is currently optimised for getting people started quickly. The simplest thing that a service team can do when getting started is to include all of the CSS and JavaScript from GOV.UK Frontend. Unfortunately, this is where most service teams stop.
This means that (anecdotally, of those we've looked at) most services include the code for all of the components, whether they're using them or not. For example, a simple service that's mostly basic form controls and buttons is likely to be including all of the code for tabs, accordions, character count despite not using them.
For example, we might:
- make changes to the code so that it's easier to selectively include bits of GOV.UK Frontend
- improve our documentation to better explain how to do this and what the benefits are
- explain the impact that this change can have in terms of web performance and sustainability, perhaps through blogging or talking about this at a monthly call
We think that doing this will:
- improve the overall performance of services across GOV.UK
- reduce the carbon footprint of services across GOV.UK
- reduce the impact on performance as we continue to add additional, more complicated components to the Design System
Epic lead
TBC
Driving role(s)
Developers, tech writers
Supporting roles
Content designer?
Needs awareness
If we plan to make some noise about this we may we want to involve the community designer and comms folks.
Further detail
This is an area where I think we can have a real 'multiplier impact' on web performance and sustainability across the GOV.UK estate just by gently nudging people towards optimising what they're including.
Although it'd be interesting to look at, I think we should consider the following out of scope (for now):
- splitting out individual features of components
- code splitting and dynamic imports
- improving caching strategies
Let's assume that most service teams will have a single JS / CSS file for their service that includes GOV.UK Frontend, and focus on getting that right before we optimise for individual pages within the service.
### Tasks
- [ ] https://github.com/alphagov/govuk-design-system/issues/3732
- [ ] https://github.com/alphagov/govuk-frontend-docs/issues/435
- [ ] https://github.com/alphagov/govuk-frontend/issues/4945
- [ ] https://github.com/alphagov/govuk-frontend-docs/issues/436
- [ ] https://github.com/alphagov/govuk-frontend/issues/4946
- [ ] Explore how get started links to other sections
- [ ] https://github.com/alphagov/govuk-design-system/issues/3745
- [ ] Create a calculator that asks people to select the components they're actually using, and then show them how much they could shave off their file size
- [ ] Share this work to a wider audience e.g. by blogging about it or running a Show & Tell
- [ ] https://github.com/alphagov/govuk-frontend/issues/4960
- [ ] https://github.com/alphagov/govuk-frontend/issues/4957
- [ ] https://github.com/alphagov/govuk-frontend/issues/4964
- [ ] https://github.com/alphagov/govuk-frontend/issues/4978
I'll leave defining the tasks we want to do until this epic is picked up, but a few thoughts on things we could do:
- https://github.com/alphagov/govuk-design-system/issues/3732 – this would help us learn where the pain points are
- move as many responsibilities from
initAll
to the components (for example, thedata-module
selector is only defined ininitAll
) to make it easier to include the JS for components withoutinitAll
- make it possible to generate a custom version of the 'dist' JS + CSS, like you could with Bootstrap in ye olde days
- improve our documentation to nudge people towards optimising what they include
- create a calculator that asks people to select the components they're actually using, and then show them how much they could shave off their file size – it could also
- ask for approx number of sessions and calculate the impact on carbon footprint
- allow the data to be submitted and feed into a dashboard with the estimated collective impact the changes have had
- blog about it
- show and tell about it
- run a clinic or workshop focused around it
Another suggestion that came up in a recent conversation with @romaricpascal – allowing users to specify which components (or other parts of the code?) they want to include the Sass for using a Sass variable:
$govuk-included-components: (
"button",
"header",
"footer"
);
@import "govuk/all";
If we're revisiting our guidance on importing things, we might want to take this opportunity to split up or re-organise the 'Import CSS, assets and JavaScript' page which is becoming a bit unwieldy.
Calling this done.