Open MorrisJohns opened 5 years ago
Uploaded edited performance-bookmarklet.js.txt with the changes made. Compare changes against the old version of performanceBookmarklet.js it was based on: https://github.com/micmro/performance-bookmarklet/blob/36cc6ee1afcfaf1a1a85933affe317e2afb18738/dist/performanceBookmarklet.js
Hi @MorrisJohns thanks a lot for your work. I will give it a proper review and update the code accordingly, but because I am moving countries in the moment I will unfortunately need another few weeks before I will get the time for this.
I have modified the performance bookmarklet so that it runs within an iframe with it's own security sandbox (so that the code is only loaded as needed, and so I don't need to audit your code much!). The performance data is passed from the "host" document to the "guest" iframe using sendMessage.
I have attached the code here to give an idea of the changes, although it would need a few hours work for anyone to use.
The function to show the performance metrics (e.g. connected to a button), run from the "host" document is:
I edited the compiled performance-bookmarklet.js (Yes this is a very dirty technique. Done because I didn't want to edit source code as then I would need to run your build process which would have taken me more time and I needed the code to work with our custom build process).
We put the following code around the performance-bookmarklet.js code (dirty: monkey patches window.performance to read the local data)
The BOOKMARKLET CODE itself also has a few modifications.
Don't read localStorage (causes exception):
Change the IFrameHolder code:
Add connection details (very important for HTTP2 connection versus HTTP1.1 connection):
Dont check for
about:
protocol:Commented out dead code:
The final change was to remove the negative right margins (replaced
-18px
and-72px
with 0 in the css style).I have written this issue so that if anyone else wants to use your code others can branch and build on these snippets. Hopefully it is useful to someone so maybe just leave the issue open?!
I really really appreciate your code - it still works beautifully (2019).