Skip to content

Instantly share code, notes, and snippets.

View Antoinebr's full-sized avatar
:octocat:
🔥

Antoinebr

:octocat:
🔥
  • Fastly
  • Paris / Rennes
View GitHub Profile
@Antoinebr
Antoinebr / img-srcset.html
Created November 10, 2016 10:35
srcset demo
<img
src="css/img/1200x800.jpeg"
media="(min-width: 320px) 300w, (min-width: 400px) 400w, (min-width: 640px) 640w, (min-width: 1000px) 1000w"
srcset="
css/img/450x400.jpeg 300w,
css/img/450x400.jpeg 400w,
css/img/768x400.jpeg 640w,
css/img/1200x800.jpeg 1000w"
alt="" class="img-responsive img-center" />
@Antoinebr
Antoinebr / server-push.php
Created November 14, 2016 16:15
server push in PHP
<?php
function push_to_browser($as, $uri) {
header('Link: ' . $uri . '; rel=preload; as=' . $as, false);
}
$assets = array(
// enter the path enter the type of file (script / style / etc...)
'<css/critical.css>' => 'style'
);
@Antoinebr
Antoinebr / appScript-onOpen.js
Created November 15, 2016 08:36
appScript-onOpen.js
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var entries = [{name: "Get Results", functionName: "getResults"}];
spreadsheet.addMenu("WebPagetest", entries);
};
@Antoinebr
Antoinebr / critical.js
Last active November 17, 2016 15:37
critical.js
var critical = require('critical');
critical.generate({
src: 'https://www.example.com', // url
dest: 'critical.css', // fichier de destination
width: 412, // largeur de la fenêtre
height: 732 // hauteur
});
@Antoinebr
Antoinebr / dont-load-hidden-img.html
Created November 22, 2016 14:33
dont-load-hidden-img.html
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
@Antoinebr
Antoinebr / lazy-loading.md
Last active May 29, 2017 10:23
lazy-loading.md

Lazy loading

For lazy loading I use lazysizes. Images can saturate the bandwith with mobile connection. We can load the images (not ATF (Above the fold) images) after the onLoad event or just before the user need them (onScroll)

@Antoinebr
Antoinebr / crp-hackathon.md
Last active June 13, 2018 08:04
Critical Rendering Path

Optimisation du chemin critique

Optimisation des JavaScript

Essayez de charger vos JS de manière non bloquantes.

Screen Shot 2016-11-28 at 2.18.28 PM.png

@Antoinebr
Antoinebr / inside-loop.php
Last active May 19, 2020 15:54
Hook to use lazysize lib
// The lazyoad class is added
<?php the_post_thumbnail('medium', array('class' => "img-responsive lazyload")); ?>
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
@Antoinebr
Antoinebr / myhooks.php
Last active August 8, 2018 14:08
loadCss with WordPress example with WooCommerce
<?php
// #1 We register LoadCss script, and we load it in the footer
// LoadCss is here -> https://github.com/filamentgroup/loadCSS/blob/master/src/loadCSS.js
add_action( 'wp_enqueue_scripts', 'register_my_scripts' );
function register_my_scripts() {
wp_enqueue_script( 'loadCss', get_template_directory_uri() . '/js/libs/loadCss.js',false, '1.2.1', true );
}