Skip to content

Instantly share code, notes, and snippets.

View mattheu's full-sized avatar

Matthew Haines-Young mattheu

View GitHub Profile
import withUniqueId from './with-unique-id';
function FormField({
id,
label,
value,
onChange,
}) {
return (
<div>
@mattheu
mattheu / gist:21481c374a207acfe8c7ca3846763e87
Last active December 1, 2023 17:52
Altis consent - Defer loading of scripts.
<?php
/**
* Defer loading of scripts until consent given (using Altis consent API).
*
* Note this requires the script to be enqueued in the normal manner.
* Scripts are loaded async so must be compatible with this, can't have dependencies etc.
*
* @package
*/
<?php
/**
* Plugin Name: Speculative Loading Eager Prerender Demo Plugin
* Description: Overrides WordPress speculative loading rules to use "eager" and "prerender" for better perceived performance.
* Version: 1.0
* Author: Matthew Haines-Young
*/
// Hook into the filter WordPress uses to generate the speculationrules script.
add_filter('wp_speculation_rules', function($rules) {
<?php
/**
* Plugin Name: Speculative Loading Eager Prerender
* Description: Overrides WordPress speculative loading rules to use "eager" and "prerender" for better perceived performance.
* Version: 1.0
* Author: Your Name
*/
add_filter(
'wp_speculation_rules_configuration',