on 2018 May 16 1:49 PM
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?
Request clarification before answering.
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/')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.