lasso-js / lasso

Advanced JavaScript module bundler, asset pipeline and optimizer
580 stars 75 forks source link

Wrap inline scripts in dom ready when slot has defer/async attribute #289

Closed scttdavs closed 5 years ago

scttdavs commented 5 years ago

When you add an external script attr of defer or async to a slot, if there is an inline script in that slot, it wraps the code in a DOMContentLoaded listener so that it will not execute before any other deferred js in the slot.

Alternatively, we could go off of the internal script attr of defer, but since an inline script cannot be deferred, we would then need to filter that attr out, or be ok with telling users to add an attr to the dom that is not valid, which may be confusing.

I'm open to suggestions here, will update docs once a direction is finalized.

DylanPiercey commented 5 years ago

Released in lasso@3.2.8, thanks for the PR 😄.