Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Louis Ramirez screenspan

View GitHub Profile
@screenspan
screenspan / webpagetest.js
Created Mar 9, 2020
Node script for running a test with WebPagetest and writing the results to InfluxDB and to file
View webpagetest.js
// Imports
const WebPageTest = require("webpagetest");
const fs = require("fs");
var download = require("download-file"); // Install download-file https://www.npmjs.com/package/download-file
const Influx = require("influx"); // Download and install InfluxDB https://v2.docs.influxdata.com/v2.0/get-started/
const influx = new Influx.InfluxDB({
host: "localhost",
database: "webpagetest",
port: 8086
});
View lazyload.js
document.addEventListener("DOMContentLoaded", function() {
var lazyImages = [].slice.call(document.querySelectorAll(".lazy > source"));
if ("IntersectionObserver" in window) {
console.log("IntersectionObserver is supported. Rock on!");
let lazyImageObserver = new IntersectionObserver(
function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
let lazyImage = entry.target;