Prevent loading JS in editor mode

I do have a script, witch converts the dates on my site (from collections) into a ‘swiss format’ (e.g. Sonntag, 1. Januar 2017). Unfortunately this script breaks the editor: I can no longer add a new entry in collections (thx to webflow-support for this hint!).

Is there any way to prevent my cutom JS (loaded bevor or in the ) be loaded in editor mode? Looking up for a special html.class (e.g. w-editor) does not work - guess, this class is added after my JS is loaded…

Simon

I think this post can help you!

Thx @AntonioBalderas. This works for me:

$(document).ready(function() {

  if (Webflow.env('editor') != undefined) {
console.log('Editor is loaded: do not load custom js');
  } else {
console.log('Editor is not loaded: load custom js...');
  }

})

But it’s not very handy: after loging out the user has to complete remove any browser data in order to the browser recognizes that he’s really logged out and custom js is loaded…

Would be nice if webflow provides an attribute for the script-tag to prevent this script from loading in editor mode. something like the embed-pagelet does (just render outside editor).

2 Likes