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

"Web-accessible files" (including js&css/web-accessible/init.js) load late/r #2459

Open
ImprovedTube opened this issue Jul 8, 2024 · 1 comment
Labels
Bug Bug or required update after YouTube changes good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥

Comments

@ImprovedTube
Copy link
Member

What might web-accessible even be good for?

  • shared libs supposedly?? - next to separation

it might helps to keep frequently called small files in the browser's in-memory cache (to check exactly)
and use APIs when CSPs might not (music detection code)

If we got rid of /web-accessible/ moving all code to /extension/ there would be no delay, we would be up and running before YT even starts loading from the server.

Looking forward! So maybe it is only good for API calls. And files /photos that can/should wait, like it sounds, or a secondary.css)

(Separation:)

in our extension code was made web-accessible along with a Manifest3 guide?
Dec7 2021 - Migrated to manifest v3 ( "web_accessible_resources":[{"resources": ["youtube-scripts.js"],"matches":["https://www.youtube.com/*"]}], )
more: #2299 (comment) )


Web-accessible files load late/r

In Firefox loading random YT clip the first js&css/web-accessible/core.js is injected right at the top, while
last js&css/web-accessible/init.js is the last node in HTML document injected long after whole thing loaded. This means there is a high chance browser already started executing YT javascript before our js&css/web-accessible/init.js runs. Bad for intercepting autoplay, bad for codecs, might even miss some early nodes in ImprovedTube.ytElementsHandler()

👍 this can be documentation for this project as long as it is like this!

dont take my word for it, test test test and verify. Might be my computer or config after all. I just rechecked and this time init.js lands just after HEAD, so it might have been my bogged Browser session. But even after HEAD is too slow - YT JS files loaded in HEAD might have started running at this point.


open devtools and look where js&css/web-accessible/ files are located in the YT html
Browser is able to inject all

  			"js&css/extension/core.js",
  			"js&css/extension/functions.js",
  			"js&css/extension/www.youtube.com/.../....js",
  			"js&css/extension/init.js"

before HTML is even fetched from YT server, but our manually injected files are injected with huge delay. In Chrome all land after HEAD. In FF and Vivaldi first few somehow manage to squeeze just before HEAD.
If we got rid of /web-accessible/ moving all code to /extension/ there would be no delay, we would be up and running before YT even starts loading from the server.

@ImprovedTube ImprovedTube added Bug Bug or required update after YouTube changes help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥ labels Jul 8, 2024
@ImprovedTube
Copy link
Member Author

thanks to @raszpl #2299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug or required update after YouTube changes good first issue A GitHub standard for inviting (new) contributors *Congratulations in advance!* help wanted Just an old github standard we add automatically. (The team can remove it when working on it.) up-for-grabs (a github standard for inviting new contributors) - Welcome! ♥
Projects
None yet
Development

No branches or pull requests

1 participant