On Tue, Oct 27, 2015 at 5:45 PM, <[email protected]> wrote:

>
> <script role="navigationLoaded"
> src="./js-opt/index_navigationLoaded.js"></script>
> <script role="visuallyLoaded" defer
> src="./js-opt/index_visuallyLoaded.js"></script>
>

How's that different from current gaia_build_index and
gaia_build_index_defer?


> <script role="editView"
> data-lazy-src="./js-opt/index_editView.js"></script>
> <script role="settingsView"
> data-lazy-src="./js-opt/index_settingsView.js"></script>
> <script role="albumView"
> data-lazy-src="./js-opt/index_albymView.js"></script>
>

In a real life example, wouldn't the view-specific files live in each of
the views?  That's probably one of the big advantages of NGA - instead of
grouping scripts with script.role, you just put them in separate html files?


> if (scriptElement.dataset.lazySrc) {
>   scriptElement.setAttribute('src', scriptElement.dataset.lazySrc);
>   scriptElement.dataset.lazySrc = undefined;
> }
>

This looks interesting, especially if it was combined with some
promise-based API like script.loaded or script.ready.

Another possibility would be to experiment with the async attribute which
doesn't guarantee the order of loading and doesn't make any other scripts
to wait for the loading to finish.  Again, script.loaded.then() could help
understand when the script actually loads.

I think you're proposing three separate things:

  1) split hot-path scripts by perf marks (which I think is similar to the
current gaia_build_* optimization, but more granular; do we need more
granularity?),
  2) group lazy loaded scripts by name (which sounds like it could be very
useful),
  3) add a declarative api for lazy loaded groups (which would also help
with #2).

Would it make sense to discuss them separately?  I'm slightly afraid of
making our build system even more magical and making our code and
optimizations less-webby.

-stas
_______________________________________________
dev-fxos mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-fxos

Reply via email to