Code Monkey home page Code Monkey logo

async-append's Introduction

Archive of async-append

This incubation is superseded by https://github.com/WICG/display-locking. This repository is archived for historical purposes.

A way to create/mutate DOM and add it to the document without blocking the main thread. For proposed solutions, see the EXPLAINER.

Problem

In order to minimize the number of DOM elements and improve load times, sites often construct elements as needed and add them to the page. Hopefully, this happens just in time for the user to see the element with no delay. In reality, the element trees constructed are quite large/complex, leading to jank.

It is also common for sites to mutate the DOM in response to user actions or data changes. When applying these changes for large sites, it is difficult to avoid jank.

Use Cases

Speaking with web developers, a few usage requests have been made for an asynchronous rendering API:

  • Appending DOM or applying changes from virtual DOM style objects constructed in a worker.
  • Async application of style sheets
  • Applying DOM mutations on the main thread normally, but while remaining responsive to input (i.e. race to finish but interrupt for input)

There are also several UX patterns that lazily instantiate and append DOM:

  • Infinite scrollings lists (news feeds)
  • Side drawers
  • Chat views
  • Image slideshows

All of these would benefit from an ability to mutate DOM without blocking the main thread.

Case Study: YouTube Gaming

YouTube Gaming constructs its comment panel for a video when the user clicks on 'comments', janking the main thread for anywhere from 55-180 ms for rendering (depending on browser). The number gets as high as 500ms when including custom element construction.

The following numbers are ms measurements averaged over 5 times.

Clicking on 'comments'

  • Chrome
    • Style: 65
    • Layout: 100
    • Paint: 15
  • Safari
    • Layout: 40
    • Paint: 15
  • Firefox
    • Layout: 40
    • Paint: 15

Scroll to bottom of 'comments'

  • Chrome
    • Style: 30
    • Layout: 15
    • Paint: 10
  • Safari
    • Layout (placeholder images): 25
    • Paint (placeholder images): 10
    • Layout (content): 25
    • Paint (content): 5
  • Firefox
    • Layout: 15
    • Paint: 10

async-append's People

Contributors

domenic avatar drufball avatar esprehn avatar marcoscaceres avatar tabatkins avatar yoavweiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

async-append's Issues

Ok to archive?

This repo hasn't had much activity for a long time... would it be ok to archive this?

Missing DOM mutation operations

@wycats has done a lot of investigation into what are the primitive DOM operations necessary to build up a tree, as part of whatwg/dom#270.

This proposal so far has:

  • append
  • prepend
  • remove
  • insertBefore

(I think maybe append and prepend could be reduced to insertBefore in theory.)

It is missing the following:

  • setAttribute
  • removeAttribute
  • setTextData (can be semi-emulated by removing the text node and inserting a new one, but that has slightly different semantics)
  • attachShadow

There is also the following non-primitive but convenient operation:

  • insertAdjacentHTML (can be emulated with <template>.content and insertBefore on the resulting DocumentFragment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.