Closed rturk closed 5 years ago
Thanks for your feedback. The plugin merely does the loading technique described in the official site. I’m down for improvements, however.
Beta branch: https://github.com/ryanditjia/gatsby-plugin-crisp-chat/tree/seo-pagespeed
Beta npm version: gatsby-plugin-crisp-chat@beta
body
tag, from head
tagdefer
attributePlease test it out and report of the result.
I'll ping crisp team and recommend the official documentation to change from async
to defer
.
Are you seeing performance improvements with the beta?
HI @ryanditjia haven't tested beta yet, will give it a try and post comments.
Briefly discussed this with the crisp team, they shared this doc https://help.crisp.chat/en/article/will-crisp-slow-down-my-website-1wfqufw/.
From the doc (bottom of the doc):
Although it's not recommend , looks like defer
is fine.
The article shows a different technique of deferring.
I briefly checked the differences between the 2 techniques and found: https://stackoverflow.com/questions/42950574/are-deferred-scripts-executed-before-domcontentloaded-event
Please try out the beta. If using defer
attribute is already showing satisfactory results, I won’t get into implementing the DOMContentLoaded technique.
IMO DOMContentLoaded
is terrible for this use case, absolutely NOT recommended. For example if a image fails to load, or any asset in the html
fails, even other scripts DOMContentLoaded
will not be trigged. This can lead to unpleasant side effects such as the crisp chat not loading at all.
IMO defer
is best, since: 1) Always will work and 2) will improve SEO and speed as discussed above
Okay, so DOMContentLoaded
is out of the picture.
Upon further reading https://flaviocopes.com/javascript-async-defer/
Looks like async
takes precedence over defer
, so I pushed another beta (3.0.0-beta.3) that removes the async
attribute as well as moves the script back to <head>
.
The plugin will follow the canonical loading technique set by Crisp, so defer
will be an option in v3 (default will still be async
).
Please give 3.0.0-beta.3 a try and let me know if you see SEO and PSI improvements.
Version 3 has been released to include the option to defer the loading of the script.
Hey guys, still seeing pretty significant impacts in web.dev scores,
Good looking site you built there. I only see one issue related to Crisp: in “Best Practices”. And it doesn’t seem related to this plugin.
Try integrating it manually via HTML and see if it improves? There is a chance that you’ll see regression instead, due to an improvement done in this issue.
Thanks man appreciate that!
We've not done any js splitting or anything yet!
Yeah it was the best practises or opportunities area that brought it to our attention its coming up as one of the heaviest script:
Sorry if its unrelated to the plugin, my bad.
After we've started to use this plugin our SEO and Google page speed was significantly degraded. We've done some research and realised that loading crisp in our new gatsby website was the root cause.
Few data points to consider
async
this is absolutely unnecessary since loading crisp chat competes with other sockets in the browserWe propose to:
aysnc defer
in the js loading script