david-mark / My-Library

The original cross-browser JS library/framework
http://www.cinsoft.net/mylib.html
59 stars 14 forks source link

My-Library needs to "use strict" #8

Open DimitarChristoff opened 11 years ago

DimitarChristoff commented 11 years ago

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

:jack_o_lantern:

WebReflection commented 11 years ago

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

kentaromiura commented 11 years ago

@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.

WebReflection commented 11 years ago

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

zivc commented 11 years ago

Is there a jQuery plugin for use strict?

david-mark commented 11 years ago

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.