Sorry, we don't support your browser.  Install a modern browser

Load only the JS and CSS modules a page actually uses (v3 public booking forms)#5266

We use Amelia 9.9.1 with a single step-by-step booking form ([ameliastepbooking]) on one page. There are no events, catalog or customer panel on the site. Even so, every booking page loads the code for all v3 modules.

What we see on the front end:

v3/public/assets/public.js statically imports all four module bundles at the top of the file:
import … from “./stepForm-….js”, import … from “./eventBooking-….js”, import “./customerPanel-….js”, import “./eventListForm-….js”.
This means the browser downloads and parses all of them, whatever the page needs:
Bundle Size (uncompressed)
stepForm 1,686 KB
customerPanel 789 KB
eventListForm 333 KB
eventBooking 96 KB
v3/public/assets/style.css (handle amelia_booking_v3_style) is a single stylesheet of about 2.5 MB uncompressed, with around 16,000 rules. Only about 400 of them match elements on a page with the step-by-step form. The comment in AmeliaBookingShortcodeService.php says the build uses cssCodeSplit: false. The stylesheet is render-blocking and is printed without a media attribute.

The impact on mobile, measured with PageSpeed Insights / Lighthouse:

Main-thread work is about 3 seconds, of which style and layout take about 550 ms.
Total Blocking Time rises noticeably when the stylesheet is made non-blocking, because the browser still has to parse the full 2.5 MB.
LCP is delayed on booking pages, where speed matters most for conversion.

We tried to fix this from our theme and could not do it cleanly:

The extra JS bundles are imported inside public.js, so there is no WordPress handle or filter to stop them.
Editing the built files is not an option, because the hashed file names change with every update.

Suggestions

Use dynamic import() per shortcode type, so a page with [ameliastepbooking] loads only the step form code. The customer panel, event list and event booking would load only when their shortcodes are present.
Enable CSS code splitting, or ship separate stylesheets per module, so the step form does not need the full 2.5 MB stylesheet.
If 1 and 2 are not possible soon, add a setting such as “Front-end modules to load” (step form, catalog, events, customer panel) with on/off toggles. A PHP filter would also work, for example amelia_v3_public_modules.
Optionally, add a filter for the media attribute or loading strategy of amelia_booking_v3_style, so sites can load it asynchronously when that suits them.

This would make Amelia noticeably lighter for the many sites that use only one booking form. It would also improve Core Web Vitals on the pages where visitors are about to book.

Thank you!

21 days ago