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

Sharing: Render Blocking Inline Javascript Injection - Dependency Deferred #6977

Closed
retrocausal opened this issue Apr 14, 2017 · 7 comments
Closed
Labels
[Closed] Duplicate Duplicate of an existing issue. [Feature] Sharing Post sharing, sharing buttons

Comments

@retrocausal
Copy link

Steps to reproduce the issue

  • You Need a website hosted.

  • Defer All Javascript Loads (Because, Nothing that Sharing-JS /Sharedaddy adds is of value to the end user. He will share it if He Reads it) - But Primarily because, perf matters!

  • Open the web console on your favourite browser and browse to the site

What I expected

No Errors

What happened instead

Look at those jQuery Dependency Failures

screenshot from 2017-04-14 06-35-27

Issue

You are Injecting Javascript, without any prior check to see if dependencies are loaded by the browser.

If the goal is to async load an external script for sharing, Why Use a HUGE Library such as jQuery to check dom loaded?
Use the Platform instead. Event listeners for domcontent loaded should suffice
Inside the callback, Do use jQuery to async fetch and load those externals by all means.

@georgestephanis
Copy link
Member

georgestephanis commented Apr 14, 2017

Alright, so the problem here is that you're deferring core scripts and are surprised that something breaks. That's not exactly a use case that we ever aimed to support.

That being said, this is something that may be worth looking into supporting in the future, but it's not an immediate concern or focus for us right now. If you write a pull request, we'll certainly review it and potentially merge it, but I'm not sure we'd devote team time into rewriting it to work with changed core script functionality.

@retrocausal
Copy link
Author

No, I am surprised that the plugin doesn't support deferring, and rooting out render blocking at the client end.
The browsers may choose to parse/download/execute JS the way they feel right. It is not in the php author's control.

So, the basic checks need to be done before injecting potentially breaking javascript when Sooo Many people subscribe to Jetpack.

As an end user of the plugin, the very least I should be able to expect, is that If I optimize my site, Jetpack integrations don't break.

I'd be happy to write a patch, but Having no prior experience with wordpress development, I am not very sure If I just modify the sharedaddy file directly. As in just get in and hard code a patch?

cheers.

@georgestephanis
Copy link
Member

Also, it's worth noting that WordPress Core itself doesn't support deferring scripts either -- for good reason, considered the complexities involved.

https://core.trac.wordpress.org/ticket/12009#comment:31

I can assure you that if WordPress Core supports defer in the future, we'll have a resolution in place to support it gracefully.


Regarding submitting a patch -- yup! Just go in, tweak it, and we'd be delighted to review and provide feedback on your changes. It's one of the reasons I first got into Open Source -- it helped me get early reviews on my code and learn what I was doing. :)

@georgestephanis
Copy link
Member

Also, if anyone wants to defer jQuery to test this, here's a gist that will let you do it.

https://gist.github.com/georgestephanis/2a84bc55ad23f4dec2cf2464109add59

You can also add a defer attribute to any script (as the first chunk is doing) and it will add it to that script as well.

@retrocausal
Copy link
Author

retrocausal commented Apr 14, 2017

Thanks @georgestephanis Much appreciated links to grok!
I will do th hard coding then, first at the plugin directory on my wordpress site, and if the patch works,
maybe you can add it as a temporary JS Injection fix before you later decide whether you need to support deferral/Async dependencies

@georgestephanis
Copy link
Member

As a general rule, if something helps edge cases such as yours, and isn't harmful or particularly large to folks in general, we'll consider it favorably for inclusion.

@jeherve jeherve added the [Feature] Sharing Post sharing, sharing buttons label Apr 19, 2017
@jeherve
Copy link
Member

jeherve commented Apr 19, 2017

Closing as duplicate of #1223 and #848

@jeherve jeherve closed this as completed Apr 19, 2017
@jeherve jeherve added the [Closed] Duplicate Duplicate of an existing issue. label Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Closed] Duplicate Duplicate of an existing issue. [Feature] Sharing Post sharing, sharing buttons
Projects
None yet
Development

No branches or pull requests

3 participants