Skip to content

Instantly share code, notes, and snippets.

View graylaurenm's full-sized avatar

Lauren Gray graylaurenm

View GitHub Profile
@JiveDig
JiveDig / functions.php
Last active December 1, 2022 21:24
Get the primary term of a post, by taxonomy. If Yoast Primary Term is used, return it, otherwise fallback to the first term.
<?php
/**
* Gets the primary term of a post, by taxonomy.
* If Yoast Primary Term is used, return it,
* otherwise fallback to the first term.
*
* @version 1.3.0
*
* @link https://gist.github.com/JiveDig/5d1518f370b1605ae9c753f564b20b7f
@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 05:24
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
@GaryJones
GaryJones / functions.php
Last active May 27, 2017 18:13
Genesis: Stop archives from using first attached image as fallback when no featured image is set.
<?php
// Don't include the above.
add_filter( 'genesis_get_image_default_args', 'prefix_stop_auto_featured_image' );
/**
* Stop Genesis archives from using first attached image as fallback when no featured image is set.
*
* @param array $args Default image arguments.
*