Skip to content

Instantly share code, notes, and snippets.

Avatar
Making Web faster

Minko Gechev mgechev

Making Web faster
View GitHub Profile
View canvas-as-favicon.html
<link rel="shortcut icon" width=32px>
<canvas style="display: none" id="loader" width="16" height="16"></canvas>
<script>
class Loader {
constructor(link, canvas) {
this.link = link;
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.context.lineWidth = 2;
View constants-side-effect.js
// constants.js
export const PI = 3.14159265357989;
localStorage.setItem('foo', 'bar');
View out-compressed.js
(()=>{"use strict";console.log(1+2)})();
View out-tree-shaken.js
/******/ (() => { // webpackBootstrap
/******/ "use strict";
// CONCATENATED MODULE: ./utils.js
// utils.js
const add = (a, b) => a + b;
const subtract = (a, b) => a - b;
// CONCATENATED MODULE: ./index.js
// index.js
View out.js
/******/ (() => { // webpackBootstrap
/******/ "use strict";
// CONCATENATED MODULE: ./operations.js
// utils.js
const add = (a, b) => a + b;
const subtract = (a, b) => a - b;
// CONCATENATED MODULE: ./constants.js
const PI = 3.14159265357989;
View strict-template-null-checks.ts
@Component({
template: '<h1>{{ article.title }}</h1>'
})
class ArticleComponent {
article: Article | undefined;
}
View strict-template.html
<div *ngFor="let todo of todos">
<h2>{{ todo.title }}</h2>
<button *ngIf="user.isAdmin">Edit</button>
</div>
View no-any.ts
import { HttpClient } from '@angular/common/http';
@Component({...})
export class AppComponent {
client: any;
constructor(http: HttpClient) {
this.client = http;
}
handleClick() {
View component-property-initialized.ts
@Component({...})
class AppComponent {
@Input() title = '';
}
View component-property-not-initialized.ts
@Component({...})
class AppComponent {
@Input() title: string;
}