adding support for script defer, improving the resolution process for data-esprima-src#22
Conversation
… data-esprima-src
lib/es6-module-loader.js
Outdated
There was a problem hiding this comment.
breaking if data-esprima-src is found in any of the current script tags, otherwise use the last script tag (assuming it is the es6-module-loader which is normally blocking the page rendering).
There was a problem hiding this comment.
Is there a way to work around this breakage? data-esprima-src is used to, in-part, resolve #13
There was a problem hiding this comment.
if you don't want to have a break in the cycle, you will have to walk all scripts in search for data-esprima-src, which is just fine, in the majority of the cases it will be few scripts, but in some edge cases we might have a lot of script tags on the page at the moment we inject the es6-module-loader (which could be inserted at the top or at the bottom btw). I didn't wanted to change too much of the code style, but I can definitely do some adjustments, specially to avoid calling getAttribute() twice, and the break. Will update the PR.
There was a problem hiding this comment.
About #13, I really don't like the global variable to set the location of esprima, I rather prefer to have a better way to detect it from the scripts in the page, considering that at least one script is going to be there anyway.
There was a problem hiding this comment.
with this approach, it will walk the array, but do not necessary touch all elements, which is a nice optimization. under ideal circumstances, we will touch the DOM once, to collect the data-esprima-src, or fallback to collect the src.
|
Any update on this? |
|
I would love to get some feedback from @guybedford before we do anything further with this pull request. |
adding support for script defer, improving the resolution process for `data-esprima-src`
|
Looks great to me... we need to document this data-esprima-src behaviour properly as well... will include a note in the readme shortly. |
|
thanks @guybedford |
If injecting
es6-module-loaderdynamically or usingdeferon the script tag, the resolution of esprimasrcis going to be a little bit more complex. Aside from that, moving theesprimaSrccomputation intoloadEsprimamethod makes more sense in preparation for forking the logic if the browser supports es6 modules.