Skip to content

Instantly share code, notes, and snippets.

View xy2i's full-sized avatar
🎈
Continuing

xy2 xy2i

🎈
Continuing
  • Grenoble INP - ENSIMAG
  • Paris
View GitHub Profile
@kamikat
kamikat / trig.scss
Last active December 7, 2023 12:50
SCSS/SASS module calculating sin/cos/tan using Taylor Expansion.
///////////////////////////////////////////////////////////
// Plain SASS Trigonometry Algorithm in Taylor Expansion //
// //
// Based on //
// http://japborst.net/posts/sass-sines-and-cosines //
///////////////////////////////////////////////////////////
$pi: 3.14159265359;
$_precision: 10;
@paulirish
paulirish / what-forces-layout.md
Last active July 22, 2024 03:38
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
wasm-pack does a bit more than just build (npm stuff), but that's really all most people care about (myself included). The relevant pieces can be traced from the build command:
https://github.com/rustwasm/wasm-pack/blob/master/src/command/build.rs#L264
Important points are the calls to step_build_wasm, step_install_wasm_bindgen, step_run_wasm_bindgen, and step_run_wasm_opt, the other 4 steps are just fluff for making a node module/npm package (the package.json allows `import {my_func} from './pkg';` instead of './pkg/${crate_name}.js'...).
step_build_wasm is simply `cargo build --lib --release --target wasm32-unknown-unknown`
https://github.com/rustwasm/wasm-pack/blob/master/src/build/mod.rs#L76
step_install_wasm_bindgen is what justifies wasm-pack's existence because whatever version of wasm-bindgen your crate depends on requires that you use a corresponding version of wasm-bindgen-cli to generate the bindings correctly. It will either use an existing install, download a precompiled version, or run `cargo