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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / .htaccess
Last active September 2, 2016 14:56
htaccess speedup !
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>
# FileETag None is not enough for every server.
<IfModule mod_headers.c>
@Antoinebr
Antoinebr / forbiden-url.php
Created March 30, 2016 17:36
Permet d'interdire des pages de l'admin
<?php
function forbidden_url(){
$forbidenUrls = array(
'theme-editor.php',
'themes.php',
'plugin-editor.php',
'plugin-install.php',
'plugins.php',
@Antoinebr
Antoinebr / gmap-distanceApi.php
Created March 21, 2016 20:46
Quick & dirty gmap API use
<!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">
<link href='http://fonts.googleapis.com/css?family=Lato:300,400' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>