sitespeedio / coach

Clear Eyes. Full Hearts. Can’t Lose.
MIT License
1.21k stars 64 forks source link

How to handle injected CSS and JS inside of head #52

Open soulgalore opened 8 years ago

soulgalore commented 8 years ago

We have a flaw in the system today, the coach don't know if a javascript or css is injected into head. Some of the advice gets screwed by that. We need to discuss how we can fix that, have a couple of ideas and will write them down later today.

soulgalore commented 8 years ago

@tobli and me discussed this offline. As we know there's no way to get the source code from the browser (let us know if you know a way) so we need to do another request to fetch it.

We want to make sure we fetch the HTML in the same session (so we will come in the same "bucket" for optimizely etc so we need to make the request from the browser when we run the javascript to collect the DOM advice. We could fetch the URL using the fetch API (setting the user agent will work right, I tested and it looked ok). What's missing from doing that today, is that the DOM scripts doesn't know anything about the run (they have no configuration = don't know if we are testing as mobile or desktop).