Categories
CLI Coding WordPress

Ergonomically Running WP-CLI in wp-env

Something that has always annoyed me is how verbose it is to run WP-CLI commands in wp-env projects. For example, to list out all posts: The “npm run wp-env run cli” part I have to copy for each command, and I often forget the right order or miss a component. It gets worse when needing […]

Categories
Coding

Running PHPUnit Automatically During Development

Recently I’ve been working on writing unit tests for a new module for the Performance Lab plugin. I realized my workflow was not particularly refined: I kept making a change to the codebase and then switching over to the terminal to re-run PHPUnit by hitting ↑ and Enter. I figured this should be done automatically […]

Categories
Coding

Sandboxing with Partytown

Partytown is a “library to help relocate resource intensive scripts into a web worker, and off of the main thread. Its goal is to help speed up sites by dedicating the main thread to your code, and offloading third-party scripts to a web worker.” Code running in a worker runs in a separate thread, ensuring […]

Categories
Coding

Auto nvm use

I use nvm to manage my version of node which makes it easy to use the right version of node for specific projects. What has annoyed me with nvm is opening up a directory in terminal and running npm only to get: I’d have to remember to run nvm install after navigating to a project […]

Categories
Coding

Unexpected Handling of Element IDs in PHP DOM

tl;dr: In PHP, make sure you remove the id attribute from a DOM element before you try to use the same id on another DOM element, even if the you already removed the first element from the document. This is not the case in browser DOM. I stumbled across something really bizarre in PHP’s document […]