Overview
GOV.UK Notify Admin uses a dual-bundle JavaScript architecture:- Modern ESM bundle (
all-esm.mjs) - ES modules for modern browsers - Legacy ES5 bundle (
all.js) - jQuery-based code for older browsers
Architecture
Module locations
ESM entry point: all-esm.mjs
The ESM bundle imports GOV.UK Frontend components and custom modules:GOV.UK Frontend initialization
Custom module initialization
Modules are initialized by querying fordata-notify-module attributes:
Legacy bundle: all.js
Combines jQuery and custom modules for older browsers:Module patterns
Modern ESM module
Example:live-search.mjs
- Check browser support with
isSupported() - Use
datasetto read configuration from HTML attributes - Update ARIA attributes for accessibility
- Trigger recalculation in related systems
Legacy jQuery module
Example:updateContent.js
- IIFE to avoid global pollution
- jQuery for DOM manipulation
- Registers on
GOVUK.NotifyModulesnamespace - Legacy module system via
modules.js
Legacy module system: modules.js
- Scans for
[data-notify-module]attributes - Converts
data-notify-module="update-content"toUpdateContent - Instantiates and starts the module
Progressive enhancement
Browser support detection
GOV.UK Frontend adds.govuk-frontend-supported to <body> when ES modules work:
Key modules
LiveSearch
Filters a list of elements in real-time: Template usage:- Case-insensitive search
- Keeps checked items visible
- ARIA live region announcements
- Triggers sticky nav recalculation
CopyToClipboard
Copies text to clipboard with visual feedback:FileUpload
Enhances file input with drag-and-drop and preview.AuthenticateSecurityKey / RegisterSecurityKey
WebAuthn implementation for hardware security keys:cbor-js for credential encoding.
UpdateContent
Polls server for updates and patches DOM efficiently: Template usage:- Adaptive polling interval based on response time
- Efficient DOM updates with
morphdom - Stops polling when
response.stop === 1 - Pauses when page is hidden
StickAtTopWhenScrolling / StickAtBottomWhenScrolling
Complex sticky positioning system (1,003 lines): Template usage:- Viewport width detection (> 768px)
- Scroll position tracking
- Shim insertion to preserve layout
- Dialog mode for stacked sticky elements
- Focus overlap detection and adjustment
- Automatic recalculation on resize
Testing
Running tests
Test configuration
Frompackage.json:
Linting
eslint.config.js (ESLint 9 flat config).
Related documentation
- Templates and Jinja - How HTML connects to JavaScript
- Static asset management - Build and deployment
- SCSS and styling - CSS architecture