yeoman / generator-polymer

Scaffold out a Polymer project
http://polymer-project.org
926 stars 150 forks source link

A couple of small changes #54

Closed trevordmiller closed 10 years ago

trevordmiller commented 10 years ago
robdodson commented 10 years ago

Which linter are you using? SublimeLinter only seems to bark when use strict is missing from an actual .js file.

I think I've fallen into the habit of not using 'use strict' when I've got script blocks in my imports. To properly isolate it you would need to wrap the contents of every script block in an IIFE, otherwise when you vulcanize all of your elements together you could cause some elements to enter strict mode which previously were not strict.

I did a really rough test using console.time to see the difference between registering 50 polymer elements with and without IIFE wrappers. On average it seems like you can register 50 elements from ~0.170ms - ~0.300ms depending on the browser.

In Chrome, adding 50 IIFEs didn't create a ton of additional overhead, typically remaining below ~0.20-0.25ms. In FF it doubled the time to around 0.80ms and in Safari it pushed the time to around 1.2ms up from 0.2ms. I'd imagine that number would be higher on mobile Safari.

I don't want to get too hung up on microbenchmarks so I guess it's worth it to consistently use strict mode and the IIFEs have the added benefit of preventing folks from accidentally creating global variables (thinking that their imports are JS scoped). I'll add the change and if folks don't like it we can think about removing it at a later date

robdodson commented 10 years ago

All of these should be fixed on master now

trevordmiller commented 10 years ago

Awesome. You are the man Rob ;) @robdodson