Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Review] Optimal performance & supportability #12

Open
9 of 13 tasks
willstocks opened this issue Feb 5, 2019 · 3 comments
Open
9 of 13 tasks

[Review] Optimal performance & supportability #12

willstocks opened this issue Feb 5, 2019 · 3 comments
Labels
enhancement Not a bug, but not a new feature - an improvement to what exists further info required Further information is required - either detail missing, or clarification is needed Good first issue This is a good starting point. Get involved - give these ones a go! help wanted Extra attention is needed
Milestone

Comments

@willstocks
Copy link
Owner

willstocks commented Feb 5, 2019

I'm going to keep this issue open for a while, just until the repo has settled a bit. Any performance-related improvements, pop a comment down below and I will add them to this list.

Current areas for improvement:

@willstocks willstocks added enhancement Not a bug, but not a new feature - an improvement to what exists help wanted Extra attention is needed question Does what it says on the tin - it's a question! Good first issue This is a good starting point. Get involved - give these ones a go! labels Feb 5, 2019
@willstocks willstocks changed the title Optimal performance - review [Review] Optimal performance Feb 5, 2019
@willstocks
Copy link
Owner Author

willstocks commented Feb 8, 2019

Multiple for loops

MOSTLY resolved as of #11. Where possible, for loops iterating through arrays have been converted to Array.forEach.


console.log alternative? Stripped most out of them from the primary scripts (non-min and min) - only concern here is impact to mobile devices. No "data" is being shared at all!

Resolved as of #11 - stripped most out of the primary scripts and deprecated the consolemessages version. Only console messages that remain relate to errors.


A fair bit of repeated code in the loadMyScript function - move into helper functions?

Resolved as of #11 - all repeated code has been refactored either into helper functions or removed.


Repeated code in init function

Resolved as of #11 - all repeated code has been refactored into micro-helper function or removed.


Always having to loop back to "core" function - can we just go step by step?

Partial resolution as of #11 - some functions now go from one, to the next, rather than core -> function -> core -> function -> core -> function


Large number of "filler" variables

Resolved as of #11 - all unnecessary vars removed, although there may be opportunity within the checkPolyfills function?


Appending script to body - is the current method the best method for all devices (not just desktop, but mobile too)?


Variables: var, let or const?

We're using const where the values are constant and don't change, and var for where they could change. Open to further suggestion (although I don't think this is going to affect performance in any way at all (if it does, we're talking nano-to-low-microseconds). Happy to be proven wrong!


if's - are they being handled in the best way in general? switch/case or continue with if else


There's a set of nested ifs within the checking function.


Complete some benchmarking on each function (and the script overall) just to see if there are any leaks/bottlenecks

See this comment, that details some basic, high-level benchmark stats for a couple of common browsers (that I have access to).


dynamicPolyfill has become potentially "Cognitively Complex"

@willstocks willstocks added further info required Further information is required - either detail missing, or clarification is needed and removed question Does what it says on the tin - it's a question! labels Feb 11, 2019
@willstocks willstocks added this to the v1.0.0 milestone Feb 11, 2019
@willstocks
Copy link
Owner Author

willstocks commented Feb 12, 2019

End to end stats (using console.time(), console.timeEnd() at the start and end of the script respectively):

  • Native features: ~180ms first run, ~40ms consecutive
  • Non-native features (2x): ~1.6s first run, 200ms consecutive

It's calling out for:

  • polyfill
  • third party script

That results in the 1.6s first run - as soon as they're in the browser cache, things are better!

All stats gathered via Codepen: https://codepen.io/willstocks_tech/pen/YBEzLW

@willstocks
Copy link
Owner Author

willstocks commented Feb 28, 2019

Using the following as a benchmark (using performance.mark and performance.measure), consecutive runs: https://codepen.io/willstocks_tech/pen/xBwJpW?editors=0012#0

Windows 10, Chrome 72 (all native features)

1st run: 180ms (empty cache)
2nd run: 137ms (cache cleared (Chrome Empty Cache and Reload))
3rd run: 19ms
4th run: 13ms
5th run: 9ms
6th run: 20ms

Windows 10, IE11

1st run: 316ms (empty cache)
2nd run: 1153ms (cache cleared)
3rd run: 117ms
4th run: 98ms
5th run: 134ms
6th run: 158ms

Windows 10, Edge 40.15063.674.0 (EdgeHTML 15.15063)

1st run: 358ms (empty cache)
2nd run: 585ms (cache cleared)
3rd run: 120ms
4th run: 89ms
5th run: 74ms
6th run: 71ms

@willstocks willstocks changed the title [Review] Optimal performance [Review] Optimal performance & supportability Feb 28, 2019
@github-staff github-staff deleted a comment Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Not a bug, but not a new feature - an improvement to what exists further info required Further information is required - either detail missing, or clarification is needed Good first issue This is a good starting point. Get involved - give these ones a go! help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant