Loading a page with amp-autocomplete will make a request to the given src without user interaction
The following code will make autocomplete make a request to /suggest without user interaction.
<form
method="get"
target="_top"
action="/search">
<amp-autocomplete
filter="none"
src="/suggest">
<input name="q"/>
</amp-autocomplete>
</form>
Chrome, not sure about other browsers
I don't think this violates any of AMP's guarantees or principles. As long as it happens after the component is laid out. What do the other @ampproject/wg-ui-and-a11y folks think?
I think it doesn't violate any of our principles, but it would probably be a nice attribute-gated feature to not fetch until user interaction, or even default behavior. Why do we currently prefetch it?
There are cases when merely focusing the autocomplete displays the currently fetched results (min-characters=0) though it isn't the default.
I can't think of a reason why an initial set of results would be useful if min-characters>0, so I'm fine getting rid of that request.
cc @caroqliu if she's still engaged though. :)
It's prefetched so the user sees a result as soon as they interact
Hmm, I guess I was describing the filter=none case, where we assume the [src] includes the autocomplete value as a parameter.
In that case I can see it being desirable to explicitly remove the first request since it may cause endpoints to calculate a bunch of results based on the empty string, which could cause a lot of server thrash.