I’d like to find out if there is a way to know in javascript if I’m in the editor mode.
I want to utilize that to pass a GTM datalayer variable to use it as a trigger to disable some tags from GTM to load as they cause the edit mode to fail to load due to Polyfill issues
“Uncaught TypeError: Cannot read property ‘_babelPolyfill’ of undefined”
For now we are using a custom trigger to check if the url contains ?edit but this doesn’t seem like the best way.
In JavaScript almost everything is an object, null and undefined are exceptions. This error occurs when a property is read or a function is called on an undefined variable. Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects. Since undefined is not an object type, calling a function or a property on such a variable causes the TypeError: Cannot read property of undefined.
If you are not sure a variable that will always have some value, the best practice is to check the value of variables for null or undefined before using them. To avoid getting these types of errors, you need to make sure that the variables you are trying to read do have the correct value. This can be done in various ways. You can do if checks before dealing with objects whose values are bound to change:
Hey Thanos did you find a solution for this?
I need a similar way for scripts and CSS to detect Editor mode easily, pref without looking for Editor: in the page title.