ampproject / ampproject/amphtml

Optimize the shopping cart page by avoiding the first flash after user interaction.

Open
#40,455 2 comments 0 reactions 0 assignees View on GitHub
Type: Feature Request
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

On your shopping page that you showed to the reader: https://amp.dev/documentation/examples/e-commerce/shopping_cart/ I tested it and noticed that after the first interaction(click on a specific add or subtract button) , there is a visual flash. This flash is only observed after the first interaction, but not after When the cart data needs to be updated in the cartitemlist state.


{

}

But this makes the user experience unpleasant or frustrating. And I have an effective method to avoid that.

### Alternatives Considered

Now, to avoid this problem, I initialized the data with AMP state via SRC from the remote source. For example...

During loading, the data will be automatically inserted into the cartitemlist state. If the user clicks any button, this updates the src file more quickly without displaying any flashing.

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the shopping cart example at https://amp.dev/documentation/examples/e-commerce/shopping_cart/ and inspect the amp-state cartItemsList initialization and the first add or subtract interaction. Reproduce the initial visual flash, then verify that the example no longer flashes after the first interaction while cart data updates.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.