This feature works similarly to Replace Globals — please read that page first. While Replace Globals renames top-level variables and functions, Protect Members renames object member names (properties and methods accessed via dot notation like myobj.value or helper.Start()).
Unlike Move Members which only hides member names behind array lookups, Protect Members permanently replaces the member names themselves.
Because member names are shared across files, this feature requires either Rename by Rules or Custom Identities to be configured. JSO requires you to explicitly specify which member names are safe to obfuscate.
The recommended approach is to prefix private members with a distinctive pattern (e.g., double underscore) and use a regex rule to match them:
var obj={ __value : 123, __dowork:function(){} }
With the regex ^__ in Rename by Rules, all members starting with double underscore are obfuscated:
var obj={ m0 : 123, m1:function(){} }
Members not matching the pattern keep their original names, so third-party code can still access them. Cross-file example:
|
a.js (before)
var obj={ __value : 123, __dowork:function(){} }
b.js (before)
function ShowMyObj(item)
{
alert(item.__value);
}
|
→ |
a.js (after)
var obj={m1:123,m2:function(){}}
b.js (after)
function ShowMyObj(a)
{
alert(a.m1)
}
|
Both files must be in the same JSO project so that member name replacements stay consistent across all files.