JS doesn't render properly in Preview mode | Community
Skip to main content
Level 2
May 6, 2020
Solved

JS doesn't render properly in Preview mode

  • May 6, 2020
  • 4 replies
  • 8782 views

Hi everyone, 

 

I experienced a few instances of the issue like this. I developed an image slider component in AEM. As you click on the pre and next button, the images are supposed to scroll to the left or the right. However the functionality doesn't work in the Preview mode. When I publish the page, the component works fine. Another problem is with the sticky menu effect on the client side. I put the code in the client lib. It doesn't work in Preview mode but it works fine when I publish the page. I was wondering if anyone knows this issue or knows if it is possible to fix it.

 

Any insight would be greatly appreciated. 

 

Lucy 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Theo_Pendle

Hi Lucy,

I can't give you a straight-up answer based on the information provided (send us some console logs! 🙂) but here are a few things to check:

  1. Are you 100% certain that the same code if deployed to your Author and Publisher instances?
  2. If the same clientlibs are deployed, it may be worth checking your browser cache. Clear it and retry (perhaps the Author instance is fetching a deprecated clientlib form cache?)
  3. Invalidate the AEM clientlib cache: http://localhost:4502/libs/granite/ui/content/dumplibs.rebuild.html
  4. Do your Author and Publisher instances implement the same code minification policies? You can check this by finding and comparing the com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl config on each instance. I've had the issue before where my code was being minified on one instance and not the other and it was causing issues (due to conflict between Webpack minification and GCC minification).

4 replies

sunjot16
Adobe Employee
Adobe Employee
May 6, 2020

 Do you see any Console errors when you see that the functionality isn't working in Preview mode?

Level 2
May 9, 2020
No there was no console errors. I found out it is actually a css issue. Thank you.
Theo_Pendle
Theo_PendleAccepted solution
Level 8
May 8, 2020

Hi Lucy,

I can't give you a straight-up answer based on the information provided (send us some console logs! 🙂) but here are a few things to check:

  1. Are you 100% certain that the same code if deployed to your Author and Publisher instances?
  2. If the same clientlibs are deployed, it may be worth checking your browser cache. Clear it and retry (perhaps the Author instance is fetching a deprecated clientlib form cache?)
  3. Invalidate the AEM clientlib cache: http://localhost:4502/libs/granite/ui/content/dumplibs.rebuild.html
  4. Do your Author and Publisher instances implement the same code minification policies? You can check this by finding and comparing the com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl config on each instance. I've had the issue before where my code was being minified on one instance and not the other and it was causing issues (due to conflict between Webpack minification and GCC minification).
Level 2
May 9, 2020
Thank you so much for your insight. I found out it was due to different css deployed to both publish and preview. Your tips are very helpful for me in the future.
Ankur_Khare
Community Advisor
Community Advisor
May 9, 2020

Could you please check how it behaves ehen u see the page as view as published mode.

And in preview mode any console errors?

Level 2
May 9, 2020
It is actually due to different css applied to both published mode and preview mode. To answer your question, in preview, the image shows as a grid, but in published view, it shows as a normal slider. There was no console error.
Level 2
May 9, 2020

Thank you everyone for the replies. After digging the code thoroughly. I eventually found out it was due to CSS. Our internal developer wrote two sets of css for both author and publish so the component looks ok in both views. However, he didn't account for preview mode which has caused a rendering issue.