Open amorey opened 7 years ago
@amorey big props for getting this released! Keep up the awesome work!
Just to confirm, this version would thus enable us to set attributes on js
and css
files before they are appended? for example, those using something like turbolinks would rely on <script></script>
element attrs such as data-turbolinks-eval="false"
which are added to prevent scripts from being evaluated after each page rendering. Does this enable this as such?
Edit:
Yes, can be achieved and rather elegantly:
<script>
loadjs([
'src-1.js',
'src-2.js',
'src-3.js',
'src-4.js',
'src-5.js',
],{
before: function(path, el) {
switch (path) {
case 'src-1.js':
case 'src-2.js':
case 'src-3.js':
el.setAttribute('data-turbolinks-eval', 'false');
}
},
success: function() {
// Do fn
}
});
</script>
@panoply Haha! Thank you! Yes, your example is correct. Setting the data-turbolinks-eval
attribute in the before
callback will cause the scripts to be added to the DOM with that attribute set.
👍
Hi Everyone,
The latest version of LoadJS (v3.5.0) includes the following new features:
Support for custom DOM insertion mechanisms via
before
callback methodSupport for custom CSS filename suffixes via "css!" prefix
An
.isDefined()
method to detect previously defined bundle definitionsSpecial thanks to @Boldewyn, @michelollivier, @sourcec0de, and @akrawchyk for their help with these features. Please try out the new version of LoadJS and let us know what you think!
Andres
https://github.com/muicss/loadjs https://www.npmjs.com/package/loadjs