Skip to content

Instantly share code, notes, and snippets.

View s3thi's full-sized avatar

Ankur Sethi s3thi

View GitHub Profile

Motivation

  • Most of abof's traffic is mobile (true for most e-commerce companies in India)
  • Old website took ~20s to load on 3G, which killed conversion rates
  • We got it down to <5s, increasing conversion rates by 40%

Part 1: Building abof.com

  • Choosing a tech stack
  • The competition: React, Angular, Angular 2, Riot, Vue
@s3thi
s3thi / app.component.ts
Created January 28, 2016 14:36
sampler.js – initialize midiInputs array
private midiInputs = [];
@s3thi
s3thi / app.component.ts
Last active January 28, 2016 14:35
sampler.js – initializeMIDI()
initializeMIDI() {
window.navigator.requestMIDIAccess()
.then((midi) => {
midi.inputs.forEach((input) => this.midiInputs.push(input));
});
}
@s3thi
s3thi / app.component.ts
Created January 12, 2016 08:48
sampler.js – gain slider (template)
`
<div><button (click)='playSample()' [disabled]='loadingSample'>play</button></div>
<div>
<label for='playbackRate'>Playback rate: </label>
<input type='range' min='0.01' max='5.0' step='0.01' [(ngModel)]='playbackRate' id='playbackRate'>
</div>
<div>
<label for='gain'>Volume: </label>
<input type='range' min='0' max='1.0' step='0.1' [(ngModel)]='gain' id='gain'>
</div>
@s3thi
s3thi / app.component.ts
Created January 12, 2016 08:42
sampler.js – gain property
private gain: number = 1.0;
@s3thi
s3thi / app.component.ts
Created January 12, 2016 08:40
sampler.js – GainNode
playSample() {
let bufferSource = this.audioContext.createBufferSource();
bufferSource.buffer = this.audioBuffer;
bufferSource.playbackRate.value = this.playbackRate;
let gainNode = this.audioContext.createGain();
gainNode.gain.value = this.gain;
bufferSource.connect(gainNode);
gainNode.connect(this.audioContext.destination);
@s3thi
s3thi / app.component.ts
Created January 11, 2016 12:41
sampler.js – playSample() with playback rate
playSample() {
let bufferSource = this.audioContext.createBufferSource();
bufferSource.buffer = this.audioBuffer;
bufferSource.playbackRate.value = this.playbackRate;
bufferSource.connect(this.audioContext.destination);
bufferSource.start(0);
}
@s3thi
s3thi / app.component.ts
Created January 11, 2016 12:39
sampler.js – playback speed (template)
`
<div><button (click)='playSample()' [disabled]='loadingSample'>play</button></div>
<div><input type='range' min='0.01' max='5.0' step='0.01' [(ngModel)]='playbackRate'></div>
`
@s3thi
s3thi / app.component.ts
Last active January 13, 2016 10:47
sampler.js – playbackSpeed
private playbackRate: number = 1.0;
@s3thi
s3thi / app.component.ts
Last active January 13, 2016 10:44
sampler.js – onClick()
onClick() {
this.playSample();
}