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
BUGFIX: Improve UI loading performance by removing UI nodedata script tag and using less data #3770
base: 8.3
Are you sure you want to change the base?
Conversation
…nodedata With this change the minimal required nodedata for each node in the rendered content is inserted as data attribute and not as inline script anymore. This improves performance as no extra function call is executed for each node. Additonally the reduction in rendered node attributes reduces the output filesize and again improves loading time. To prevent just-in-time loading of nodes all incomplete nodedata is requested after the guest frame has finished loading.
I'm not sure how breaking this could be right now, therefore draft for now ;) @grebaldi I remember you started working on a replacement for the script tag, so your insights here would be very welcome. This doesn't need to be included in 8.3 but maybe we can :) |
Some test results with 82 nodes (haven't found a good way to measure time to interactive with the iframe): With Script Tag + with full PropertiesDocument size: 245KB / 14.6KB Without Script Tag + with MinimalProperties + ondemand node loadingDocument size: 198KB / 13.3KB (~80%) Without Script Tag + with MinimalProperties + Node batch loadingDocument size: 198KB / 13.3KB (~80%) |
* | ||
* @var Locale | ||
*/ | ||
protected $rememberedUserLocale; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those changes related?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a 100%, just some optimisation as the locale is switched twice for every node triggered by the augmentation
I tested a variant of this change in my customers project and the document size was reduced from 1.8mb to 1.2mb. Also there are two child nodes queries for each node to get document and content child nodes. Maybe we also don't need those for the initial rendering with some adjustments. Right now it would break some parts of the ui. |
OK optimised a bit more and completely removed nodedata from the guest frame: Without NodeData in augmenterDocument size: 108KB / 7.5KB (~44%) When clicking through the demo site each page is about 50% quicker to load which actually feels much nicer. |
Great initiative, thanks for taking care. |
Yes of course. At the end we need the same amount of nodedata. But we kill the overhead of the function calls and document parsing. |
@bwaidelich I tested the loading performance a while yesterday with "Fast 3G" connection + Caching in my local Dev Context. Result: The page loads much faster, but if you try to immediately edit text in a CKEditor, the first click only selects the element instead of showing the caret to start editing. The second click then works. I want to test this on an actual remote server in Production Context to get a feeling for it. I also checked whether I can adjust the LoadingBar to wait for the GuestFrame to be initialised, but this is not a simple change right now. I would make sense to have a loading indicator of some kind for the guest initialisation too. This is already currently problem, when We currently also load some nodes twice as the structure tree needs them too. I want to check whether I can then skip some of them. |
Thanks for taking care of this. As a side effect, this will also help with some CSS selectors, as with the current approach selectors like |
Realised today this will also fix the issue neos/neos-development-collection#2988 with the Fusion Augmenter when augmenting a single content element. Previously it added another tag as it counted the element itself and the script tag instead of modifying the outside tag of the content element. |
The two main performance hogs which makes the async request for the nodedata slow is in It seems this was less of a problem in the previous version as during rendering the same first-level-node-cache was automatically used where possible. Right now I'm getting great results by optimising \Neos\Neos\Ui\ContentRepository\Service\NodeService::getNodeFromContextPath in skipping the creation of a completely new context with site and domain for each requested node. |
5242e1d
to
c439582
Compare
What I did
With this change the minimal required nodedata for each node in the rendered
content is inserted as data attribute and not as inline script anymore.
This improves performance as no extra function call is executed for each node.
Additonally the reduction in rendered node attributes reduces the output filesize and again improves loading time.
To prevent just-in-time loading of nodes all incomplete nodedata is requested after the guest frame has finished loading.
One big benefit of that is that the scripts tags won't interfere with JS plugins anymore and using the Fusion Augmenter will not wrap a single object with a ContentWrapping with another tag due to the script tag.
Fixes neos/neos-development-collection#2988
How to verify it
preview
document should be smaller (10-30%) than before and load quicker (10-40%)