-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 🚀 🚀 amp-carousel ssr: allow render without JS 🚀 🚀 🚀 #37646
Conversation
6cf0678
to
5e6d167
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM so far w/ 1 minor tweak but in draft so will hold off approving
5e6d167
to
a2c5200
Compare
fa06836
to
ac9c39b
Compare
Hey @Jiaming-X, @jeffkaufman! These files were changed:
Hey @jridgewell! These files were changed:
|
for the reviewer
|
@@ -229,6 +231,8 @@ function buildSlideScrollCarousel(element) { | |||
slidesContainer.appendChild(slideWrapper); | |||
slideWrappers.push(slideWrapper); | |||
}); | |||
// Initialize the first slide to be shown. | |||
slideWrappers[0]?.classList.add(ClassNames.SLIDES_ITEM_SHOW); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Move this into the forEach
above? Also, why isn't it a map
…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. Why should this be part of the forEach (it should only occur to a single elem) and what should be a map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, instead of arr.forEach it could be arr.map.
Agreed!
Mind if I punt on that to a small PR tomorrow? (unless you have more feedback and I need to rerun CI anyway)
src/core/dom/style.js
Outdated
* @return {string} hyphen-cased string | ||
*/ | ||
export function camelCaseToHyphenCase(camelCase) { | ||
return camelCase.replace(/[A-Z]/g, (match) => '-' + match.toLowerCase()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webkitFoo
can be lowercase, but still needs a leading dash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find!
This seems tricky to handle for opera
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
There seem to be a long-tail of test cases that create a fake |
@jridgewell: ready for a rereview |
* amp-carousel ssr: allow render without JS * lint. scrollslide working * rcebulko feedback * further fixes * hyphen-case setProperty and remove Set * fix test * add an extra test * moar fix * solve lowercase vendor bug. * even moar test fixes (cherry picked from commit a50f171)
* amp-carousel ssr: allow render without JS * lint. scrollslide working * rcebulko feedback * further fixes * hyphen-case setProperty and remove Set * fix test * add an extra test * moar fix * solve lowercase vendor bug. * even moar test fixes (cherry picked from commit a50f171)
summary
Server-rendering AMP Components should allow us to have UI visible without blocking on JS executaion.
Via disabling JS locally, I was surprised to see that this wasn't the case yet.
We still have two issues stopping
<amp-carousel>
from rendering without JS:<style>
link to the CSS to the<head>
.layoutCallback
instead ofbuildDom
. In this case it is the addition ofi-amphtml-element
andi-amphtml-slide-item-show
.I solve (2) in this PR, and am working on (1) separately.
🚀 🚀 🚀 results 🚀 🚀 🚀
For webpages with their LCP Element in the amp-carouse, we can expect a ~40% improvement to LCP. source