addyosmani / timing.js

Navigation Timing API measurement helpers
1.5k stars 114 forks source link

Fix broken window object in browser-side commonjs environment #26

Closed rhysd closed 8 years ago

rhysd commented 8 years ago

In browserify context, this is not a Window object on commonjs module. So, when we use browserify, timing.js cannot find window.performance properly and getTimes() always returns false.

I fixed this by exporting module via module.exports explicitly instead of using this.

rhysd commented 8 years ago

@addyosmani

I rebased this PR against master branch and checked the latest works on my project.

parshap commented 8 years ago

Can this change get published to npm, please?