My-Library icon indicating copy to clipboard operation
My-Library copied to clipboard

My-Library needs to "use strict"

Open DimitarChristoff opened this issue 11 years ago • 5 comments

Not using strict is contrary to best practice advice by Douglas Crockford and other people that seem to know JavaScript well.

:jack_o_lantern:

DimitarChristoff avatar Oct 30 '13 17:10 DimitarChristoff

although "use strict" is known to have undesired side effects such as slowing down parsing and in some case execution. It was stated in es-discuss that this directive wasn't created to improve performance. #justmy2cents

WebReflection avatar Oct 30 '13 17:10 WebReflection

@WebReflection I think the directive can be useful though for avoiding malicious code that rely on eval or similar to override the Object or the Function constructor and act as a rootkit basically stealing informations, this applies only to a very little cases, when one can run js before your script (well actually even after in some cases), passing codes as a string. Obviously this sort of protection applies only on browser which supports the use strict directive. http://caniuse.com/#feat=use-strict. And that mean that your server is still compromise at that point.

kentaromiura avatar Oct 30 '13 17:10 kentaromiura

if it's about security, use strict removes the possibility to obtain the real window through function(){return this}() too but the bug was opened just because Mr. D Crock thinks is something everyone should use.

All I was trying to say is that, performance a part that could be slightly compromised and AFAIK this library is famous for being the fastest out there, there might be reasons to not use that directive.

JSLint ain't a good reason to put everything under use strict. Then it's not my business, so I just read the tweet and commented as I felt ;-)

Off this thread now, all the best

WebReflection avatar Oct 30 '13 17:10 WebReflection

Is there a jQuery plugin for use strict?

zivc avatar Oct 30 '13 17:10 zivc

Dimitar: Crockford knows JS, but not cross-browser scripting. Common sense says that the library does not need "use strict". And thanks WebReflection. I agree with you on this one. zivc: No.

david-mark avatar Nov 04 '13 22:11 david-mark