I also spent quit a bit of time to figure this one out. Please use the polymer-cli@next
instead of polymer-cli
Plain polymer-cli
doesn't seem to have the latest build and optimizations to support Polymer 2.0#Preview related functionality.
You can install polymer-cli@next
. In Ubuntu, you can simply use npm install -g polymer-cli@next
Then on, the bundled and unbundled versions of the application generated through polymer build
would just works fine.
Edit:
You can find my sample Polymer2.0#Preview version of the code at https://github.com/phani1kumar/phani1kumar.github.io branch is "devmaster".
the sw-precache-config.js
is initial render-blocking. This will load all the resources that the main page needs to make the app available for offline use. src/lazy-resources.html
loads resources for the next routes.
You would need to get a proper configuration based on your layout and main page in the following 3 files:
sw-precache-config.js, polymer.json, src/lazy-resources.html
. This is a practice followed in the shop app from Polymer team, you may opt to a different mechanism for lazy loading. The bottom-line for lazy loading is to load the resources after Polymer.RenderStatus.afterNextRender
.
You may also find the following article interesting: https://medium.com/@marcushellberg/how-i-sped-up-the-initial-render-of-my-polymer-app-by-86-eeff648a3dc0#.pi2iucwzi