Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

The browser strikes back

The browser strikes back

Modern browsers give us powerful tools for layout, animation, state, storage and more - the kinds of things we once had to reach for JavaScript libraries and frameworks to achieve. Now we need to learn to treat the browser as an ally, rather than an enemy - and discover how leaning into its native capabilities can unlock simpler, faster and more resilient ways to build.

Avatar for Jono Alderson

Jono Alderson

December 18, 2025
Tweet

More Decks by Jono Alderson

Other Decks in Education

Transcript

  1. Jono Alderson Independent technical SEO consultant Image source: LINK Popover

    API <button popovertarget="mypopover"> Toggle popover </button> <div id="mypopover" popover> Popover content </div>
  2. Jono Alderson Independent technical SEO consultant Image source: LINK form:has(:invalid)

    { outline: 1px solid red; } .field:has(input:invalid) label { color: red; } .field.password:has(input:focus) .strength-hint { opacity: 1; }
  3. Jono Alderson Independent technical SEO consultant Image source: LINK <picture>

    <!-- Wide layout --> <source media="(min-width:800px)" type="image/avif" srcset="/img/hero-wide.avif 1x, /img/[email protected] 2x" width="1200" height="600"> <!-- Mobile art direction --> <source media="(max-width:799px)" type="image/webp" srcset="/img/hero-tall.webp 1x, /img/[email protected] 2x" width="600" height="900"> <!-- Fallback --> <img src="/img/hero.jpg" srcset="/img/hero-400.jpg 400w, /img/hero-800.jpg 800w, /img/hero-1200.jpg 1200w" sizes="(max-width:600px) 100vw, (max-width:1200px) 80vw, 1200px" loading="lazy" decoding="async" fetchpriority="low" alt=""></picture>
  4. Jono Alderson Independent technical SEO consultant Image source: LINK <picture>

    <!-- Wide layout --> <source media="(min-width:800px)" type="image/avif" srcset="/img/hero-wide.avif 1x, /img/[email protected] 2x" width="1200" height="600"> <!-- Mobile art direction --> <source media="(max-width:799px)" type="image/webp" srcset="/img/hero-tall.webp 1x, /img/[email protected] 2x" width="600" height="900"> <!-- Fallback --> <img src="/img/hero.jpg" srcset="/img/hero-400.jpg 400w, /img/hero-800.jpg 800w, /img/hero-1200.jpg 1200w" sizes="(max-width:600px) 100vw, (max-width:1200px) 80vw, 1200px" loading="lazy" decoding="async" fetchpriority="low" alt=""> </picture>
  5. Jono Alderson Independent technical SEO consultant Image source: LINK <script

    type="speculationrules"> { "prefetch": [ { "where": { "href_matches": "^/" }, // same-origin navigations "eagerness": "moderate" // hover 200ms or pointerdown } ] } </script> Speculation rules
  6. Jono Alderson Independent technical SEO consultant Image source: LINK "prerender":

    [ { // Only prerender links you explicitly opt-in "where": { "selector_matches": "a[data-prefetch='prerender']" }, "eagerness": "immediate" }, { // Or prerender highly likely next pages (e.g., paginated articles) "where": { "and": [ { "href_matches": "^/article/[^#?]+$" }, { "selector_matches": "a[rel='next']" } ] }, "eagerness": "conservative" // on pointer/touch down } ] Speculation rules "prefetch": [ { // High-value links you’ve explicitly marked up "where": { "selector_matches": "a[data-prefetch]" }, "eagerness": "immediate" }, { // Fallback for most internal links, but exclude sensitive routes "where": { "and": [ { "href_matches": "^/" }, { "not": { "href_matches": "^/(logout|cart|checkout|admin)" } }, { "not": { "selector_matches": "a[data-prefetch='off']" } } ] }, "eagerness": "moderate" } ]
  7. Jono Alderson Independent technical SEO consultant Image source: LINK Native

    caching Cache-Control: public, max-age=600, s-maxage: 86400, stale-while-revalidate=86400
  8. Jono Alderson Independent technical SEO consultant Image source: LINK Native

    storage <script> const b=document.body, k='theme'; b.dataset.theme = localStorage[k] || 'light'; theme.onclick=()=>{ b.dataset.theme = b.dataset.theme==='light'?'dark':'light'; localStorage[k]=b.dataset.theme; }; </script>
  9. Jono Alderson Independent technical SEO consultant Image source: LINK “In

    our experiment with popular web pages, 17 out of 20 showed improvements, and the average foreground parse and compile times reduction was 630ms” //# allFunctionsCalledOnLoad Compile hints
  10. Jono Alderson Independent technical SEO consultant Image source: LINK <div

    hidden="until-found"> <!-- hidden content --> </div> Hidden until found
  11. Jono Alderson Independent technical SEO consultant Image source: LINK <ul>

    <li class="card">[...]</li> <!-- many <li> cards ... --> </ul> .card { content-visibility: auto; /* skip layout/paint offscreen */ contain-intrinsic-size: 400px 300px; /* reserve space to avoid CLS */ } Content visibility
  12. Jono Alderson Independent technical SEO consultant Image source: LINK .card

    { contain: layout paint style; /* or: contain: content; */ /* content = layout+paint+style+size (in most engines) */ } Containment
  13. Jono Alderson Independent technical SEO consultant Image source: LINK .hero

    img { transition: transform .3s ease; will-change: transform; /* pre-promotes layer */ } .hero img:hover { transform: scale(1.05); } Change management
  14. Jono Alderson Independent technical SEO consultant Image source: LINK Intersection

    Observers <footer id="footer">…</footer> <script> const io = new IntersectionObserver(e => { document.body.classList.toggle( 'near-footer', e[0].isIntersecting); }, { rootMargin: '200px' }); io.observe(document.querySelector('#footer')); </script>
  15. Jono Alderson Independent technical SEO consultant Image source: LINK BFcache

    & business logic window.addEventListener('pageshow', function (event) { if (event.persisted) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: 'bfcache_restore' }); } });
  16. Jono Alderson Independent technical SEO consultant Image source: LINK <section

    class="accordion" id="faq"> <h3 class="acc-item"> <button class="acc-btn" aria-expanded="false" aria-controls="a1">What is X?</button> </h3> <div id="a1" class="acc-panel" role="region" aria-hidden="true">Answer A…</div> <h3 class="acc-item"> <button class="acc-btn" aria-expanded="false" aria-controls="a2">How do I Y?</button> </h3> <div id="a2" class="acc-panel" role="region" aria-hidden="true">Answer B…</div> </section> <style> .acc-panel { max-height: 0; overflow: hidden; transition: max-height .25s ease; } .acc-btn[aria-expanded="true"] + .acc-panel { max-height: 20rem; } .acc-btn { width: 100%; text-align: left; } </style> <script> (function () { const acc = document.querySelector('#faq'); const buttons = acc.querySelectorAll('.acc-btn'); function closeAll() { buttons.forEach(btn => { btn.setAttribute('aria-expanded', 'false'); const panel = document.getElementById(btn.getAttribute('aria-controls')); panel.setAttribute('aria-hidden', 'true'); }); } function toggle(btn) { const expanded = btn.getAttribute('aria-expanded') === 'true'; closeAll(); // one-at-a-time behavior; remove if multi-open btn.setAttribute('aria-expanded', String(!expanded)); const panel = document.getElementById(btn.getAttribute('aria-controls')); panel.setAttribute('aria-hidden', String(expanded)); } buttons.forEach(btn => { btn.addEventListener('click', () => toggle(btn)); btn.addEventListener('keydown', e => { if (e.key === ' ' || e.key === 'Enter') { e.preventDefault(); toggle(btn); } if (e.key === 'ArrowDown') { e.preventDefault(); btn.closest('.acc-item').nextElementSibling?.nextElementSibling?.previousElementSibling?.querySelector('.acc-btn')?.focus(); } if (e.key === 'ArrowUp') { e.preventDefault(); btn.closest('.acc-item').previousElementSibling?.previousElementSibling?.querySelector('.acc-btn')?.focus(); } }); }); })(); </script>
  17. Jono Alderson Independent technical SEO consultant Image source: LINK <details

    class="faq"> <summary>What is X?</summary> <p>Answer A…</p> </details> <style> summary {cursor:pointer;list-style:none} summary::after {content:'▸';float:right;transition:.2s} details[open] summary::after {transform:rotate(90deg)} </style>