FWIW, there's a WebGPU extension which 'harmonizes' uniform buffer struct layout with other address spaces, but currently it's only implemented in Chromium-based browsers:
Ticket: https://github.com/gpuweb/gpuweb/issues/4973
Caniuse: https://caniuse.com/?search=uniform_buffer_standard_layout
The std140-style layout restrictions are basically a leftover when GPUs used vec4 "register tables" for uniform data.