fryn / html5slider

<input type=range> polyfill for Firefox
http://fryn.github.io/html5slider/
180 stars 48 forks source link

Make it work with Closure Compiler's ADVANCED_OPTIMIZATIONS #12

Closed adrianholovaty closed 11 years ago

adrianholovaty commented 11 years ago

Hey there,

I refactored html5slider to be able to work with Google Closure Compiler's ADVANCED_OPTIMIZATIONS. This requires some rather unintuitive changes, so I'd understand if you didn't want to merge it upstream, but here goes nothing. :)

Thanks for the library!

Adrian

fryn commented 11 years ago

Interesting changes. I am not familiar with the "advanced optimizations" of the Closure Compiler. From reading through the documentation, it seems that they recommend the following: "However, for properties used only within your compiled code, use dot syntax." Doesn't that mean not to switch most of the property usages in the code to the quoted string syntax? If I am mistaken, why was "mozSetImageElement" switched to the quoted string syntax but not "dispatchEvent"? Secondly, when the Closure Compiler isn't used, executing the quoted string syntax is slower than the dot syntax. :(

adrianholovaty commented 11 years ago

I changed the properties in styles because the code relies on the property names (the element.style.setProperty() call in style()). It's true, though, that thumb doesn't technically need it.

The mozSetImageElement thing is ugly. Closure Compiler magically knows about certain properties of window that it shouldn't rename -- but mozSetImageElement isn't one of them. So I needed to switch that one because otherwise the compiler would rename it.

adrianholovaty commented 11 years ago

I definitely recommend running Closure Compiler on this for yourself to see what it does. I believe they have a Web version that lets you paste in code and see the results.

fryn commented 11 years ago

It's cool that you made this modification, and after investigation, I have found Closure Compiler rather useful. Thanks for the tip. However, I'm not interested in modifying the non-minified version of this particular JS library just to be more compatible with minification/"compilation" engines.

html5slider was always meant to be a temporary polyfill until built-in support landed in Firefox, and the good news is that built-in support for has landed in Firefox developer builds (aka "nightlies") and should be turned on in release builds within a few months.

adrianholovaty commented 11 years ago

Sure, sounds fine to me -- makes sense! :-)