Skip to content

Instantly share code, notes, and snippets.

View mleibman's full-sized avatar

Michael Leibman mleibman

View GitHub Profile
@mleibman
mleibman / instrument-route-resolve.js
Created November 15, 2017 16:58
Instrument AngularJS route resolvers to time them and visualize on the performance timeline in Chrome DevTools.
angular.element(document).injector().invoke(($injector, $rootScope) => {
const patchedSymbol = Symbol('patched');
$rootScope.$on('$routeChangeStart', (e, next, current) => {
if (!next.resolve) return;
Object.keys(next.resolve).forEach(key => {
const resolver = next.resolve[key];
if (resolver[patchedSymbol]) return;