Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View futtta's full-sized avatar
⏲️
Always busy optimizing matters.

frank goossens futtta

⏲️
Always busy optimizing matters.
View GitHub Profile
@futtta
futtta / autoptimize_defer_inline_jquery.php
Last active November 11, 2022 21:43
POC to defer inline JS that requires jQuery
<?php
add_action('plugins_loaded','ao_defer_inline_init');
function ao_defer_inline_init() {
if ( get_option('autoptimize_js_include_inline') != 'on' ) {
add_filter('autoptimize_html_after_minify','ao_defer_inline_jquery',10,1);
}
}
function ao_defer_inline_jquery( $in ) {
@futtta
futtta / persist-admin-notices-dismissal.php
Created December 13, 2020 08:20
quick draft of how "maximum times seen" could work
<?php
/**
* Persist Admin notices Dismissal
*
* Copyright (C) 2016 Collins Agbonghama <http://w3guy.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@futtta
futtta / gallery-data-link-example.html
Created February 17, 2020 11:20
Example HTML output of a WordPress page with a gallery block which adds a data-link attribute.
@futtta
futtta / ao_css_defer.php
Last active April 22, 2019 09:40
experimental code snippet to have AO load full CSS later
<?php
add_filter('autoptimize_filter_css_preload_onload','__return_empty_string');
add_filter('autoptimize_css_preload_polyfill','defer_iso_preload');
add_filter('autoptimize_html_after_minify','preload_to_aodeferload');
add_filter('autoptimize_filter_css_replacetag','inject_css_in_footer');
function defer_iso_preload() {
return '<script data-cfasync="false">!function(n){"use strict";n.loadCSS||(n.loadCSS=function(){});var o=loadCSS.relpreload={};o.bindMediaToggle=function(e){var t=e.media||"all";function a(){e.addEventListener?e.removeEventListener("load",a):e.attachEvent&&e.detachEvent("onload",a),e.setAttribute("onload",null),e.media=t}e.addEventListener?e.addEventListener("load",a):e.attachEvent&&e.attachEvent("onload",a),setTimeout(function(){e.rel="stylesheet",e.media="only x"}),setTimeout(a,3e3)},o.poly=function(){for(var e=n.document.getElementsByTagName("link"),t=0;t<e.length;t++){var a=e[t];"aodeferload"!==a.rel||"style"!==a.getAttribute("as")||a.getAttribute("data-loadcss")||(a.setAttribute("dat