I created one component before activation of the locker service. After that i created another component after activation of the locker service. But my doubt is how to know, what is the difference between with and without locker service using code. Can anybody explain on this through code.

  • Can you please explain why you would need to know the difference? If you are starting new development on lightning components locker service will be enabled automatically. Not sure what you are achieving by seeing the difference
    – RedDevil
    Jul 5, 2018 at 12:21
  • @RedDevil, If we don't need to know means, Why we are using lightning locker service? what is the main purpose of use? what is the difference of using before and after activation of the locker service? if you know please explain me
    – JohnCena
    Jul 5, 2018 at 12:26

1 Answer 1


This is outlined in What is Locker Service? and its related links. What you really need to know is that if you follow the documentation correctly, there is no difference in behavior between having Locker Service and not. What Locker Service does is prohibit certain types of behaviors, such as trying to peek into the DOM of a component outside your own namespace.

For example, Locker Service disallows the following code example:

<lightning:button aura:id="button1" label="My Button" />


var element = component.find("button1").getElement();

In other words, Locker Service makes your code secure so that other components can't modify your component's internal structure. It also protects system elements from being modified in unexpected ways.

There's a lot more than just this, so I really suggest you read the documentation. Locker Service makes your code more secure, but also means that it is more challenging to use because somethings that you think are allowed are not. It's really all about protecting you from writing insecure code.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .