JS functions names collision

405
1
03-28-2019 03:03 AM
MarkKovler
New Contributor

I'm trying to use  ArcGIS JavaScript map component on the same page with Jodit WYSIWYG HTML editor. Both components use obfuscated JavaScript code. The problem is that the obfuscated code of both components uses the same replacements for functions names, which leads to collision. For example, both codes contain a top level function named "O". As the result, a call to the function leads to a wrong code (it depends on the order of loading of JavaScript files). On my opinion, the problem could be solved by using namespaces in your source JavaScript files.

0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor

3x or 4x? I can't think of any global functions in the JSAPI. The only method names that are obfuscated during the optimization process like that are names that scoped in a function, for example.

require(["m1","m2","m3"], function(a, b, c) {
  // scoped to this function, not global
  // sometime later when it is used
  var a2 = a(arg);
});

‍‍‍‍‍‍

No namespacing required.

They should have no conflicts with any other libraries. If there are conflicts with that library it could be they are obfuscating global function names.I would think they would just shadow it though. Tough to tell.