Skip to content

Instantly share code, notes, and snippets.

View screenspan's full-sized avatar

Brian Louis Ramirez screenspan

View GitHub Profile
@screenspan
screenspan / webpagetest.js
Created March 9, 2020 13:16
Node script for running a test with WebPagetest and writing the results to InfluxDB and to file
// 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
});
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;