This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new PerformanceObserver((list) => { | |
const lcpEntry = list.getEntries().at(-1); | |
if (!lcpEntry.url) { | |
// In case LCP is a <p> or <h1> etc (not a resource w url) | |
console.log('LCP: ', lcpEntry.startTime, lcpEntry.element); | |
console.log('LCP element outerHTML: ', lcpEntry.element.outerHTML); | |
return; | |
} | |
const navEntry = performance.getEntriesByType('navigation')[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Browser Compatibility: | |
IE: 9, Safari: 3.1, Chrome: 1, Edge: 12, Firefox: 3.5 | |
*/ | |
function getSiblings(el, sel) { | |
var matches = []; | |
var targets = sel ? el.parentNode.querySelectorAll(sel) : el.parentNode.children; | |
for (var target of targets) { | |
if (target !== el && target.parentNode === el.parentNode) { | |
matches.push(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Include this file early and then initialize your Swipers using | |
* swiperLazyInit(...). Swiper lib can then be loaded async or later. | |
* | |
* Re-configure example: var slideshow = new Swiper("#slideshow", { speed: 400 }); | |
* Becomes: swiperLazyInit("#slideshow", { speed: 400 }, function(slideshow) { }); | |
*/ | |
function swiperLazyInit(swiperContainer, parameters, callback) { | |
if (window.Swiper) { | |
// fix with init to break up the creation and initialization of the swiper in two parts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Responsive test tool</title> | |
<style> | |
body { | |
margin: 0; | |
background-color: #111; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run on for example https://connect.garmin.com/modern/comparison?activityId=111&activityId2=222&activityId3=333 | |
(function() { | |
function str2time(text) { | |
var t = text.trim().replace(',', '.').split(':').reverse(); | |
return (parseInt(t[2]) || 0) * 3600 + (parseInt(t[1]) || 0) * 60 + (parseFloat(t[0]) || 0); | |
} | |
function time2str(time) { | |
var s = (time % 60).toFixed(0); | |
return Math.floor(time / 60) +':'+ (s < 10 ? '0' + s : s) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
// Outputcache | |
$cache_time_in_seconds = 600; | |
$cache_file_name = 'news-external.b.php.outputcache'; | |
$echo_output_after_save = true; | |
if (file_exists($cache_file_name)) { | |
// Cache exists | |
if (time() - filemtime($cache_file_name) < $cache_time_in_seconds) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
// Credit to Alex Siepman and digEmAll on StackOverflow (answer https://stackoverflow.com/a/18321594/1049710) | |