Expand my Community achievements bar.

SOLVED

JS doesn't render properly in Preview mode

Avatar

Level 2

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 

1 Accepted Solution

Avatar

Correct answer by
Level 10

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).

View solution in original post

8 Replies

Avatar

Employee

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

Avatar

Level 2
No there was no console errors. I found out it is actually a css issue. Thank you.

Avatar

Correct answer by
Level 10

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).

Avatar

Level 2
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.

Avatar

Community Advisor

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

And in preview mode any console errors?

Avatar

Level 2
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.

Avatar

Level 2

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.