Share
Embed
Transcript
105 slides
-
This is all way too complicated and too much code
for a website... My CTO from almost 10 years ago -
SPA MPA SSG SSR Edge Rendering (Partial) Hydration Server Components
Resumability It's a lot! -
2013 Hello world! 10KB / 50KB 2023 Hello world! 100KB
/ 300KB* Complexity * powered by 200MB+ of text files #node_modules -
I do feel overwhelmed by the pace of change. [...]
JavaScript is meant to feel overwhelming. It’s where we try stu! out. It’s where stu! moves fast. Jeremy Keith Source: "Building" presentation -
The web platform still isn't ready... (but we'll get there
sooner than later) -
A cross-browser effort to reach a state where each technology
works exactly the same in every browser. Interop Source: wpt.fyi/interop-2023 -
A cross-browser effort to reach a state where each technology
works exactly the same in every browser. Interop Source: wpt.fyi/interop-2023 -
Aspect Ratio Cascade Layers Color spaces and functions Dialog Grid
Flex Subgrid Containment Scrolling Interop 2022 * * This list is not complete. -
Container Queries :has() Inert @property Import Maps Font features color-mix
:nth-child(of syntax) Interop 2023 * * This list is not complete. -
.toggleBtn { anchor-name: -#my-anchor; } #something { -#width: 15rem; -#height:
5rem; anchor-default: -#my-anchor; position-fallback: -#left-to-bottom; } -
.toggleBtn { anchor-name: -#my-anchor; } #something { -#width: 15rem; -#height:
5rem; anchor-default: -#my-anchor; position-fallback: -#left-to-bottom; } @position-fallback -#left-to-bottom { @try { top: calc(anchor(center) - var(-#height) / 2); left: calc(anchor(right)); } @try { top: calc(anchor(center) - var(-#height) / 2); right: calc(anchor(left)); left: auto; } } -
@position-fallback -#left-to-bottom { @try { top: calc(anchor(center) - var(-#height) /
2); left: calc(anchor(right)); } @try { top: calc(anchor(center) - var(-#height) / 2); right: calc(anchor(left)); left: auto; } } ! -
.box { -#my-color: PaleVioletRed; background: rgb(from var(-#my-color) r g b);
} rgb(219 112 147) Relative colors -
.box { -#my-color: PaleVioletRed; background: rgb(from var(-#my-color) r g b);
} rgb(219 112 147) Relative colors -
.box { -#my-color: PaleVioletRed; background: rgb(from var(-#my-color) g r b);
} rgb(112 219 147) Relative colors -
.box { -#my-color: PaleVioletRed; background: rgb(from var(-#my-color) g b r);
} rgb(112 147 219) Relative colors -
.box { -#my-color: PaleVioletRed; background: hsl(from var(-#my-color) h s l);
} hsl(340deg 60% 65%) Relative colors -
.box { -#my-color: PaleVioletRed; background: hsl(from var(-#my-color) h s calc(l
+ 20%)); } hsl(340deg 60% 85%) Relative colors -
.box { -#my-color: PaleVioletRed; background: hsl(from var(-#my-color) h 0% calc(l
+ 20%)); } hsl(340deg 0% 85%) Relative colors -
.box { -#my-color: PaleVioletRed; background: oklch(from var(-#my-color) calc(l + 0.2)
c h); } oklch(0.87 0.13 0.68) Relative colors -
.card { .container { display: flex; flex-direction: column; gap: 1em;
} .header { aspect-ratio: 3 / 2; } & h2, & p { margin: 0; } } Waiting for Firefox 116 (Shipping in ~3 weeks) Photo by Ben Michel on Unsplash -
.card { .container { display: flex; flex-direction: column; gap: 1em;
} .header { aspect-ratio: 3 / 2; } & h2, & p { margin: 0; } } Waiting for Firefox 116 (Shipping in ~3 weeks) ' Photo by Ben Michel on Unsplash -
.card { h1 {} } .card { & h1 {}
} .card { :is(h1) {} } Valid Valid X Invalid -
.card { container-type: inline-size; .container { display: flex; flex-direction: column;
@container (width > 400px) { flex-direction: row; } } } -
.card { container-type: inline-size; .container { display: flex; flex-direction: column;
@container (width > 400px) { flex-direction: row; .header { flex: 0 0 25cqw; } } } } -
.card { container-type: inline-size; .container { display: flex; flex-direction: column;
@container (width > 400px) { flex-direction: row; .header { flex: 0 0 25cqw; } } } } cqw 1% of a query container's width cqh 1% of a query container's height cqi 1% of a query container's inline size cqb 1% of a query container's block size cqmin The smaller value of either cqi or cqb cqmax The larger value of either cqi or cqb -
.container { container-type: size; height: 12rem; } @container (orientation: portrait)
{ .portrait { display: grid; } .landscape { display: none; } } -
.card { container-type: inline-size; .container { display: flex; flex-direction: column;
} &:has(img[src*="dog"]) { background: url(./dog.svg); } } Behind a flag -
article:has(aside) { /% ..' *) } form:has(:invalid) { /% ..'
*) } :root:has(.menu-toggle[aria-pressed=”true”]) { /% ..' *) } label:has(+ input) { /% … *) } -
CSS has become a more complete mature language, that works
better with the way we build websites today. Una Kravets Source: The state of the CSS community -
<picture> <!-, load webp images if supported --/ <source type="image/webp"
srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=webp 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=webp 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px"> <!-, load traditional supported image format --/ <img srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=jpg&fl=progressive 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=jpg&fl=progressive 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), -
sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw -
8em), 550px"> <!-, load traditional supported image format --/ <img srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=jpg&fl=progressive 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=jpg&fl=progressive 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" src="https:/0images.ctfassets.net/..'/paris.jpg" alt="Buildings of Paris" loading="lazy" decoding="async" width="1243" height="1500"> <1picture> -
<picture> <!-, load webp images if supported --/ <source type="image/webp"
srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=webp 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=webp 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px"> <!-, load traditional supported image format --/ <img srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=jpg&fl=progressive 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=jpg&fl=progressive 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" src="https:/0images.ctfassets.net/..'/paris.jpg" alt="Buildings of Paris" loading="lazy" decoding="async" width="1243" height="1500"> <1picture> -
<picture> <!-, load webp images if supported --/ <source type="image/webp"
srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=webp 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=webp 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px"> <!-, load traditional supported image format --/ <img srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=jpg&fl=progressive 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=jpg&fl=progressive 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" src="https:/0images.ctfassets.net/..'/paris.jpg" alt="Buildings of Paris" loading="lazy" decoding="async" width="1243" height="1500"> <1picture> type="image/webp" -
<picture> <!-, load webp images if supported --/ <source type="image/webp"
srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=webp 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=webp 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px"> <!-, load traditional supported image format --/ <img srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=jpg&fl=progressive 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=jpg&fl=progressive 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" src="https:/0images.ctfassets.net/..'/paris.jpg" alt="Buildings of Paris" loading="lazy" decoding="async" width="1243" height="1500"> <1picture> srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=webp 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=webp 200w, ..'" -
<picture> <!-, load webp images if supported --/ <source type="image/webp"
srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=webp 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=webp 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px"> <!-, load traditional supported image format --/ <img srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=jpg&fl=progressive 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=jpg&fl=progressive 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" src="https:/0images.ctfassets.net/..'/paris.jpg" alt="Buildings of Paris" loading="lazy" decoding="async" width="1243" height="1500"> <1picture> sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" -
<picture> <!-, load webp images if supported --/ <source type="image/webp"
srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=webp 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=webp 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px"> <!-, load traditional supported image format --/ <img srcset=" https:/0images.ctfassets.net/..'/paris.jpg?w=100&fm=jpg&fl=progressive 100w, https:/0images.ctfassets.net/..'/paris.jpg?w=200&fm=jpg&fl=progressive 200w, ..'" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" src="https:/0images.ctfassets.net/..'/paris.jpg" alt="Buildings of Paris" loading="lazy" decoding="async" width="1243" height="1500"> <1picture> loading="lazy" sizes=" (max-width: 768px) calc(100vw - 3em), (max-width: 1376px) calc(50vw - 8em), 550px" -
<img loading="lazy" width="200" height="200" sizes=" (max-width: 768px) calc(100vw - 3em),
(max-width: 1376px) calc(50vw - 8em), 550px" srcset="swing-200.jpg 200w, swing-400.jpg 400w, ..'" src="swing-400.jpg" alt="Kettlebell Swing"> -
<img loading="lazy" width="200" height="200" sizes="auto" srcset="swing-200.jpg 200w, swing-400.jpg 400w, ..'"
src="swing-400.jpg" alt="Kettlebell Swing"> -
<img loading="lazy" width="200" height="200" sizes="auto" srcset="swing-200.jpg 200w, swing-400.jpg 400w, ..'"
src="swing-400.jpg" alt="Kettlebell Swing"> If images are lazy loaded, let the browser pick the best size. -
function transitionStuff(data) { /0 For non-Chromiums if (!document.startViewTransition) { updateTheDOMSomehow();
return; } /0 browser: ( (old) document.startViewTransition(() =3 { updateTheDOMSomehow(); /0 browser: ( (new) }) } -
Video platforms Blogs Shops Image & Illustration software Marketing sites
Games Productivity Apps PWAs Streaming sites Social Networks -
If your site feels like a "boring" Multi Page App,
maybe it should be one? -
If JavaScript doesn't bring users joy, thank it, and throw
it away. Marie Kondo -
If JavaScript doesn't bring users joy, thank it, and throw
it away. Marie Kondo Addy Osmani Source: The Cost of JavaScript 2023