Skip to content

Instantly share code, notes, and snippets.

View sdrjs's full-sized avatar

Sergey sdrjs

View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active November 14, 2024 11:03
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@dSalieri
dSalieri / index.md
Last active July 2, 2024 14:06
Аргумент resolve внутри Promise и Promise.resolve работают ли они одинаково?

Вопрос: Есть две цепочки promise, которые выводят сообщения в консоль. Первый выводит: tick1, tick2, tick3. Второй: tick3, tick1, tick2

Код 1:

/// Код 1
const p = new Promise(resovle => setTimeout(resovle));

new Promise(resolve => resolve(p)).then(() => {
    console.log("tick 3");
});
@dSalieri
dSalieri / index.md
Last active August 6, 2024 14:53
Promise изнутри

Автор: dSalieri

Версия ECMAScript, используемая в объяснении: Draft ECMA-262 / June 24, 2022

Версия WHATWG, используемая в объяснении: Living Standard - 22 August 2022

Последнее изменение документа: 13.12.2022