Development questions

What is Lightning Web Security (LWS) and how does it differ from Locker Service?

DevelopmentMedium

Both isolate components from each other for security, but they work differently.

  • Locker Service wraps objects in secure proxies (SecureElement, SecureWindow), which can break third-party libraries and adds overhead.
  • Lightning Web Security is the newer architecture that isolates each namespace in its own JavaScript sandbox using the standard browser APIs with distortions only where required. It is faster, supports more third-party libraries, and is closer to standard JS behaviour.

Salesforce recommends LWS and it is enabled in Session Settings. Both are designed to stop one namespace from accessing another's DOM or data.

lwcsecuritylwslocker