-
Notifications
You must be signed in to change notification settings - Fork 33
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
Difference in resources loaded on client when having visual editing configured #1024
Comments
Thank you so much for the thorough report. It's immensely helpful for us when people take the time to raise issues in this way. I do remember initially trying to support what you're describing re: minimal client, but there are definitely complexities. Mainly the issue of visual editing being enabled at build, but potentially "disabled" at runtime per user. I can't promise too much on the minimal client optimisation for now. However this dependency issue seems like it could be an oversight somewhere and potentially an easy fix, so I'll definitely do some investigation into that today. |
So I'm not seeing quite the same results as you using our Nuxt starter. I do see a slight increase in the entry size, but the same number of files. Would you be able to add the following to your Nuxt config and provide similar screenshots (Visual editing enabled/disabled) so I can see the output file names? Thanks!
|
Essentially, I can just see the entry file size is increased because of the |
Sure! With visual editing configuredWithout visual editing configuredWith minimal clientThis is the Vue file for the page I'm testing this on
|
I think it's originating from
and those files in turn also have additional dependencies. the
Won't really matter in terms of what files to load, because these imports will be included during build time. |
Hm, strange that it thinks that visual editing is enabled for me then 🤔 I'm just using the defaults, no additional code anywhere other than the nuxt config I sent earlier as well as the Vue file. When you say "disabled at app level" are you adding any additional logic or configuration somewhere? |
I'm using |
That is very strange, I don't think Can you check that you aren't seeing any |
I don't see that div in the root of Could be nothing, but I see that in your screenshot you're filtering on "JS" in the network tab. If I do that, most of the additional resources in my screenshots are filtered out because they are listed as "text/javascript" (no idea why devtools wouldn't include that in that filter though). |
Ahh right. I see the issue you're describing now! I believe this is Nuxt's default behaviour, to |
👍 On top of that, in my tests I also see a sizeable difference in the document size itself as well as the entry file. But I don't know if that's caused by the bundler splitting the chunks differently. But still a bit weird. With visual editing configured (see the highlighted rows)Without visual editing configured (see the highlighted rows)Tested running a lighthouse score on it as well, got 62 in performance when visual editing was configured and 89 without it. |
Having done some investigation, it looks like we would need to use the Nuxt's However, we have to resolve the filenames themselves in the module's It's not pretty, I'll keep looking. |
As per request from @rdunk in #1023, here's more info on what I've found in relation to resources loaded when having visual editing configured.
Wasn't sure what to label this as, not really a bug and not really a feature request 😅
I might be totally off here and just looking at this from the wrong angle, but to me, it looks like that when having
visualEditing
section configured in thenuxt.config.ts
, the page will load with quite a lot more resources.What I did is create a blank Nuxt project with this module and set up a page that loads a document from Sanity. That page is using the
useSanityQuery
. In my Nuxt config, I'm just toggling the visualEditing section on/off, running a build and then opening the page withnuxi preview
. I have not gone into Sanity Studio (not even running it) and the Presentation tool. I am just loading this page as any regular non-editor user would.With visual editing configured
Results in
Without visual editing configured
Results in
What I think this stems from is the way the module is set up. We are checking the visual editing config in build time and swapping out the client composables with those meant for visual editing. These composables import additional dependencies and therefore will cause more resources to be loaded on the client no matter if you're actually using visual editing at the moment or not.
The best scenario would be if we'd only load the additional resources when visual editing has been enabled. Only way to achieve this currently, is to deploy two versions of the same site. One "public production build" for all normal traffic where visual editing config is removed, and one "editing production build" that Sanity Studio would connect to and has the visual editing config set up.
In addition, if we can figure out a way to load the visual editing stuff conditionally, it would open up for further optimisation by allowing us to use the "minimal client" (
minimal: true
) when a user is not currently using visual editing.As a comparison, using the minimal client results in these resources being loaded
Let me know if I can help with anything!
Versions
module: 1.11.4
nuxt: 3.12.3
The text was updated successfully, but these errors were encountered: