This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include link tags for CSS resource download timings (#2518)
* Include link elements in resource download timings * Add changeset * Make resource type more extensible * Return explicit unsupported value rather than null
- Loading branch information
1 parent
3fce520
commit fbf76bc
Showing
4 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@shopify/performance': patch | ||
--- | ||
|
||
Performance now emits CSS resource download timing data when initiated by a link tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {getResourceTypeFromEntry} from '../utilities'; | ||
import {EventType} from '../types'; | ||
|
||
describe('utilities', () => { | ||
describe('getResourceTypeFromEntry()', () => { | ||
it('returns "unsupported" for unsupported initiator types', () => { | ||
expect( | ||
getResourceTypeFromEntry({ | ||
initiatorType: 'audio', | ||
} as PerformanceResourceTiming), | ||
).toBe('unsupported'); | ||
}); | ||
|
||
it('returns stylesheet event type when initiatorType is css', () => { | ||
expect( | ||
getResourceTypeFromEntry({ | ||
initiatorType: 'css', | ||
} as PerformanceResourceTiming), | ||
).toBe(EventType.StyleDownload); | ||
}); | ||
|
||
it('returns script event type when initiatorType is script', () => { | ||
expect( | ||
getResourceTypeFromEntry({ | ||
initiatorType: 'script', | ||
} as PerformanceResourceTiming), | ||
).toBe(EventType.ScriptDownload); | ||
}); | ||
|
||
it('returns stylesheet event type when initiatorType is link and file extension is .css', () => { | ||
expect( | ||
getResourceTypeFromEntry({ | ||
initiatorType: 'link', | ||
name: 'file.css', | ||
} as PerformanceResourceTiming), | ||
).toBe(EventType.StyleDownload); | ||
}); | ||
|
||
it('returns script event type when initiatorType is link and file extension is .js', () => { | ||
expect( | ||
getResourceTypeFromEntry({ | ||
initiatorType: 'link', | ||
name: 'file.js', | ||
} as PerformanceResourceTiming), | ||
).toBe(EventType.ScriptDownload); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters