Skip to content

Instantly share code, notes, and snippets.

@hakimelek
hakimelek / script.js
Created June 29, 2018 15:53
Detect Latest Image loaded on the page
const imagePath = '/path/to/image'
let latestImageTiming = 0
const p = window.performance.getEntriesByType('resource')
p.filter(e => { e.name.indexOf(imagePath) >= 0 && (latestImageTiming = Math.max(latestImageTiming, e.responseEnd))})
console.log(latestImageTiming)
@hakimelek
hakimelek / webperf.js
Created August 22, 2017 20:18
Web performance object
/**
* Web performance object example:
*/
import 'performance-polyfill';
class WebPerfMetrics {
constructor() {
this.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
this.timing = (this.performance && this.performance.timing) ? this.performance.timing : null;
@hakimelek
hakimelek / cache-control.js
Created June 8, 2017 20:09
Set cache control for assets except html
if (process.env.NODE_ENV === 'production') {
app.use('/drive/search/public', express.static(__dirname + '/../public'), {
maxAge: '1d',
setHeaders: setCustomCacheControl
});
} else {
app.use('/drive/search/public', express.static(__dirname + '/../client/src'));
}
@hakimelek
hakimelek / priceline.com.har
Created February 26, 2019 22:47
HAR file for Priceline.com
This file has been truncated, but you can view the full file.
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [
{
"startedDateTime": "2019-02-25T15:10:35.824Z",
@hakimelek
hakimelek / sitemap.xml
Last active July 6, 2022 13:33
Priceline Demo Sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.priceline.com/</loc>
<lastmod>2022-07-06</lastmod>
</url>
<url>
<loc>https://www.priceline.com/hotels</loc>
<lastmod>2022-07-06</lastmod>
</url>
@hakimelek
hakimelek / us_institutions.json
Created September 28, 2016 09:36
A List of American Colleges and Universities in JSON format
[
{
"institution": "Alabama A & M University"
},
{
"institution": "University of Alabama at Birmingham"
},
{
"institution": "Amridge University"
},