Timeline for Bootstrap file input styler
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 23, 2017 at 12:40 | history | edited | CommunityBot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
Mar 23, 2017 at 10:12 | history | bounty ended | Ismael Miguel | ||
Mar 16, 2017 at 16:01 | comment | added | Ismael Miguel |
That's correct, but it is a given that any Javascript code will be minimified to reduce it's network fingerprint (in adition to gzipping). I'm in no way saying that your review is bad or wrong. It isn't. But, considering minification, my code isn't optimal. I've forgotten to add a single ; before the code, just in case it gets all mangled. One this that escaped me is that the first parameter on the load event is an instance of jQuery. That is, jQuery(document).ready(function($){ [...] }); allows me to use $(); inside the code, even if someone runs jQuery.noConflict() .
|
|
Mar 16, 2017 at 14:56 | comment | added | Tushar | @IsmaelMiguel I didn't consider minification process when writing the answer. Your both points are valid. The review stands for the given code. Also, minification is not mentioned in the question. | |
Mar 16, 2017 at 14:40 | comment | added | Ismael Miguel |
You're right, it isn't required anymore. Assuming your code is written into a single file and isn't minified and "mangled" with a load of other javascript files. (I think Wordpress does this, to reduce HTTP roundtrips). And those files are all wrapped in an eval() (not window.eval() !, that has a different scope) or a Function() . If one script has var window = <stuff>; , you broke the code. Try this: jsfiddle.net/tznsa59s
|
|
Mar 16, 2017 at 14:35 | comment | added | Tushar |
@IsmaelMiguel regarding the window safeguard, I don't think it is required anymore. For window.jQuery and jQuery will refer to same object as there is no local variable named jQuery in the IIFE. Only thing is that jQuery will require scope chaining till global object where it is defined. And as explained, IIFE can be removed here.
|
|
Mar 16, 2017 at 14:28 | comment | added | Ismael Miguel |
[...] You should read the "Additional Notes" section on the :file pseudo-selector. I TOTALLY agree with "caching" $this.attr('id') . I don't know how it escaped me. For that bit alone, you deserve an upvote. But then, I disagree about your attr() vs data() . The intention is to only use attributes. Using data() can hide the name of the attributes that you can use. This exposes another issue: no documentation. But using attr() doesn't seem an issue. Also, I had no idea that bind() is deprecated. That's entirelly new to me. I will replace it with .on() .
|
|
Mar 16, 2017 at 14:24 | comment | added | Ismael Miguel |
You made good points, but you also some I really disagree. Using Function('return this')() is just an insane safeguard, in case the window object isn't the window . Also, window.jQuery and jQuery , inside that anonymous function, is very different. Outside, anything can happen, and the window variable can have/be anything. About using :file , I agree that it is readable but it is a performance nightmare. You can read about what happens on codereview.stackexchange.com/a/101207 (I describe what happens to pseudo-selectors, like :file ). [...]
|
|
Mar 16, 2017 at 14:20 | history | edited | Tushar | CC BY-SA 3.0 |
Used `data()` instead of `attr('data-*')`
|
Mar 16, 2017 at 13:53 | history | answered | Tushar | CC BY-SA 3.0 |