WP Codex
How To Lazy Load Background Images In WordPress With Intersectionobserver
WordPress already adds loading="lazy" to images. Use IntersectionObserver for things the browser cannot lazy load by itself, like CSS background images.
How To Add Smooth Scroll To Anchor Links In WordPress
The shortest solution is pure CSS: add html { scroll-behavior: smooth; } to your stylesheet. If you need more control, use this JavaScript version.
How To Add A Copy To Clipboard Button In WordPress
Use the navigator.clipboard API to copy any text with a single click. It requires HTTPS.
How To Load A Script As An Es Module In WordPress
Filter the script tag with script_loader_tag to output type="module" for a specific handle.
How To Use The WordPress Rest Api With Javascript Fetch
Expose the REST root URL and a nonce with wp_localize_script(), then call any endpoint from JS.


