Hacker Newsnew | past | comments | ask | show | jobs | submit | ebidel's commentslogin

Yes and no. In some cases (3rd party content that you don't control), there's no way to know what script/iframe is going to do/use. For example, ads script that uses `document.write()` and kills perf.

Turning on certain policies can also help you be certain quality/standards are being met across your site. For example, the creative team forgets to optimize images and you end up shipping many more MBs of images than actually needed. The `image-compression` feature policy could be used as a gut check to make sure that never happens.


full example of screenshoting a DOM element:

https://github.com/GoogleChrome/puppeteer/issues/306#issueco...


Make sure you're using Chrome 59. If you don't have that yet, try Chrome Canary.


The Google Chrome website installs v58 when I press download, and when I try to install Canary:

"Chrome Canary is currently not available on the Linux platform."


If your system is already configured to use Google Chrome's apt repo (e.g. after installing a stable Chrome), you can do:

    apt-get install google-chrome-unstable


Get a build of Chromium that is more recent than this feature


Any ideas on how to print landscape with no margin ?



As noted, you'll need the --disable-gpu flag for now. Hopefully that will go away around ~Chrome 60.

See

- https://bugs.chromium.org/p/chromium/issues/detail?id=546953...

- https://bugs.chromium.org/p/chromium/issues/detail?id=695212


Be convenient if all the examples had it for those of us idly pasting stuff in while code compiles :-)


FWIW, we created the Github issue tracker b/c it's a bit more approachable for everyone. Github is also a much better place for discussions.


Ah, that makes sense.

Monowall is kind of poor. The inability to edit comments is particularly annoying.


Windows support is coming. You can follow along at https://bugs.chromium.org/p/chromium/issues/detail?id=686608


If your app uses a huge amount of code, then yes. But that's really the fault of the app developer. Not the library.

What developers often do is pull in a ton of components from the web components catalog and not realize that every component comes with a cost. It's no different than working with libraries. Know the tradeoffs.

There are plenty of examples of fast rendering apps that written with Polymer. Check out https://shop.polymer-project.org/ and https://www.chromestatus.com/features, to name two.

https://ebidel.github.io/polymer-experiments/polymersummit/f... is another example that shows how to utilize the "upgrade" feature [1] of the custom elements API. IOW, the browser can render markup without JS ever running. Unfortunately, this is not something that Polymer leverages very much. It requires more work and is less friendly to new developers.

[1]: https://developers.google.com/web/fundamentals/getting-start...


Also relevant: "Cache-Aware Server Push (Client Side)" https://docs.google.com/document/d/1HhmyzKUPuWcCs8wG_GLSu3mv...

The Chrome team is hashing out potential solutions to the server push <-> browser cache problem.


In using shadow DOM, one thing that's become clear is that it is a developer productivity tool (built in the browser).

With React, you have to use inline styles (https://facebook.github.io/react/tips/inline-styles.html) or a build tool to modularize/prefix CSS selectors (e.g. CSS Modules). Inline styles can muck with specificity and tons of inline styles can actually force the browser to do more context switching than necessary (HTML parser <-> CSS parser). Mind you, the latter is unlikely to actually be a perf issue in a real app.

In shadow dom, you just write CSS. Write simple selectors in a `<style>` or a stylesheet, the browser automagically scopes the selectors to the component, no tools required. Shadow roots also prevent outer styles from cross the boundary and leaking in. That one is particularly tricky without help from the browser.

As for perf...

In theory, the browser can optimize work (style recalcs, layout, paint) in shadow trees b/c the DOM is local.

However, generally there's a lot of low hanging fruit still to look at. Browser engines have been optimized for global css so those paths are super fast right now. https://bugs.chromium.org/p/chromium/issues/detail?id=314303 is a good example of the work that can be done (now fixed in Blink):

> Being inside a ShadowRoot disables lots of optimizations we have for the normal document. Authors also use ShadowRoots differently than the main document (ex. hundreds of tiny identical sheets in each Shadow instead of one really big one in the document) so we should consider those use cases and how we can handle them better.

> We should be able to get much faster. This bug tracks the many efforts to make recalcStyle faster in ShadowRoot (and by extension Web Components)

Another thing Blink does is optimize `<style>`s so they're shared/cached across instances of a component (as long as their `.textContent` is the same). That was a pretty big speed up in Blink.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: