cancel
Showing results for 
Search instead for 
Did you mean: 

Loading js dependencies for smartedit

Former Member
0 Kudos
730

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?

View Entire Topic
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/')