How do I prevent certain javascript from running inside the Oxygen editor?

Sometimes there is a situation when a certain script that you have inserted through Code Block causes problems in the Oxygen editor, or for some other reason you do not need this script to be executed in the editor. I want to show you a trick that I often use in such cases.

To block the execution of the script in the editor, sufficiently before the beginning of your script, insert the line if($('html').attr('ng-app') == 'CTFrontendBuilder') return; and the following code will not work..

Example of usage in Code Block:

jQuery(document).ready(function($) {

    if($('html').attr('ng-app') == 'CTFrontendBuilder') return;
	
    //Next, your code, which will work only in the public part of the site
	
});
How do I prevent certain javascript from running inside the Oxygen editor?

That is all. It's simple. I hope the advice will help you.

Follow the release of new tips and tutorials:
arrow-up