cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Loading js dependencies for smartedit

Former Member
0 Likes
900

My storefront templates include a few bits of javascript that are required for SmartEdit.

This includes the following lines:

 <template:javaScriptVariables />
 
 <script type="text/javascript" src="${commonResourcePath}/js/jquery-2.1.1.min.js"></script>
 
 <script type="text/javascript" src="/_ui/addons/smarteditaddon/shared/common/js/webApplicationInjector.js"></script>
 <script type="text/javascript" src="/_ui/addons/smarteditaddon/shared/common/js/reprocessPage.js"></script>
 <script type="text/javascript" src="/_ui/addons/smarteditaddon/responsive/common/js/smarteditaddon.js"></script>
 

None of these are required outside SmartEdit, that is, they are completely redundant for our storefront.

Is there either:

  • A condition I can wrap all of this in, which only passes true if the current context is SmartEdit, so that none of this is loaded for customers visiting the storefront

  • A separate layout / template for SmartEdit that I can move all this to?

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member192125
Participant

I ran into this issue too. The problem is there's no way to differentiate between the SmartEdit preview and the regular page using the browser session or Spring model. The solution is to use javascript to check if the parent window is from SmartEdit. Load the scripts only if it is so. Do a check with something like this:

window.parent.location.toString().includes('/smartedit/')
Former Member
0 Likes

Have you found any solution to this by now?

Edit:

One thing I found is the isEnabled() method in the CMSSmartEditDynamicAttributeService

Former Member
0 Likes

not yet!

Former Member
0 Likes

Hi Ben,

Have you got a way to deal with this problem?