This is a simple snippet for adding a loading screen to a Polymer application. It is useful if your Polymer application is rather large and some users may be on a very slow internet connection.
The basic idea is that a very simple (and small) loading screen page will be loaded by the browser. When the browser has fully loaded and displayed the loading page then it will start loading all the files required for the Polymer application.
For a further speed improvement: the loading.css
, and polymerAppLoader.js
files can be placed inline with the index.html
thus reducing the amount of files to be loaded from the server.
filestoload.html
is a seperate file so that the usual grunt/gulp build functions can still be applied as before. Shouldn't require re-writting your build scripts.
Any improvements/comments are encouraged.
Works like a charm on desktop, but running into problems on mobile. It seems that filetoupload.html never actually loads from these two lines:
tag.setAttribute('onload', 'polymerLoader.insertPolymerApplication()'); document.getElementsByTagName('head')[0].appendChild(tag);
The onload callback is never called, and no errors are thrown when listening for the error event on the link tag. Doesn't seem to be anything wrong with the html file being loaded. You ever encounter anything like this?