-
Notifications
You must be signed in to change notification settings - Fork 4
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
CLD-338-rendering-PGW #41
base: master
Are you sure you want to change the base?
CLD-338-rendering-PGW #41
Conversation
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.
@asad-rafter I'm afraid that this is not in the right direction. This uses onload, but also dynamically injects the script ensuring it will be loaded much later than needed. This slows down the loading of the PGW which causes increases in the LCP.
window.cldProductGallery is not assigned in
Line 12 in 018a043
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" /> |
Could this be the issue?
Yes, this is the issue. So the problem is, sometimes in milliseconds difference <script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" /> loads late and the cloudinary object from other scripts assigned to window.cldProductGallery, in that case it breaks the PGW because the script is not available in DOM. Let me know if you have any better solution for this |
@asad-rafter The new code adds loading time, and still allows such a condition. Please remove the onload changes and assign window.cldProductGallery after Line 12 in 018a043
|
PGW is only called on PDP, where we are using the onload. |
@asad-rafter You'll add a script tag immediately following the above script tag, so it will look like this: <script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" />
<script>
window.cldProductGallery = cloudinary;
</script> |
@yuval-cloudinary We were already using this and it was causing issue, that's why we change it on onload |
|
@asad-rafter I don't think we had this way. Can you share a link to the previous time? |
|
Having this syntax is equivalent, do I don't mind it: <script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary;" /> As long as this snippet is part of the rendered HTML and is not injected after the page load |
@yuval-cloudinary the requested changes has been updated |
window.renderCloudinaryGalleryWidget(); | ||
} | ||
</script> | ||
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary; window.renderCloudinaryGalleryWidget();"> </script> |
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.
@asad-rafter this call to window.renderCloudinaryGalleryWidget() is (possibly) executed before we have the div "cld-gallery" in the DOM.
Are we able to inject it after the "
If so, then we would be able to remove the additional call to the function after the document is ready:
https://github.com/asad-rafter/cloudinary_sfcc_site_cartridge/blob/9ab65cc0dbeaa7e3ec12e9e4a1fc869096563d6d/cartridges/int_cloudinary/cartridge/js/cloudinaryWidgets.js#L5
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.
@yuval-cloudinary cld-gallery is already present in DOM, there is no issue with it, everything seems to be working
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.
@asad-rafter When reviewing the generated HTML on view-source:https://zzgt-007.dx.commercecloud.salesforce.com/s/RefArch/electronics/televisions/flat%20screen/vizio-vp504fM.html?lang=en_US I see that the script tag is written before the div tag.
Please move this line to the lower part of the ISML, remove the second call on the cloudinaryWidgets.js and deploy for testing
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.
@yuval-cloudinary do you want to remove window.renderCloudinaryGalleryWidget();
from script tag?
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.
@asad-rafter I like the window.renderCloudinaryGalleryWidget(); in the script tag, it just needs to be added lower at the rendered HTML
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.
@yuval-cloudinary changes have been made and deployed on 007
@@ -53,6 +50,7 @@ | |||
<iscomment>Custom start: add cloudinary PGW</iscomment> | |||
<isif condition="${pdict.cloudinary && pdict.cloudinary.isEnabled && (pdict.cloudinary.galleryEnabled || pdict.cloudinary.isGalleryEnabled)}"> | |||
<isinclude template="product/components/cloudinaryGallery" /> | |||
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary; window.renderCloudinaryGalleryWidget();"> </script> |
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.
Please remove the legacy calls to renderCloudinaryGalleryWidget from https://github.com/asad-rafter/cloudinary_sfcc_site_cartridge/blob/984285740779e611bacfdcb5f6cc623a559ff505/cartridges/int_cloudinary/cartridge/js/cloudinaryWidgets.js#L93
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.
@yuval-cloudinary made the changes
@@ -55,6 +52,10 @@ | |||
</div> | |||
</div> | |||
<isinclude template="product/components/setItems" /> | |||
|
|||
<isif condition="${dw.system.Site.current.preferences.custom.CLDGalleryEnabled}"> | |||
<script src="${dw.system.Site.current.preferences.custom.CLDGalleryJSURL}" onload="window.cldProductGallery = cloudinary; window.renderCloudinarySetGalleryWidgets();"></script> |
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.
Please remove the legacy calls to renderCloudinarySetGalleryWidget from https://github.com/asad-rafter/cloudinary_sfcc_site_cartridge/blob/984285740779e611bacfdcb5f6cc623a559ff505/cartridges/int_cloudinary/cartridge/js/cloudinaryWidgets.js#L95
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.
thanks @asad-rafter
No description provided.