CarbonPackages / Carbon.IncludeAssets

Include your assets (css, js) in an easy way into Neos
GNU General Public License v3.0
14 stars 5 forks source link

Loading selective css async? #2

Closed jobe451 closed 6 years ago

jobe451 commented 6 years ago

I have 2 css files, one with essential instructions - that I want to load regularly (blocking). One with additions, that I would like to load asynchronously (none-blocking). Is that possible?

jobe451 commented 6 years ago

Well, it seems that this is not possible. I added this to my fusion package as a hack to make it possible:

  prototype(Carbon.IncludeAssets:File) {
      isFile {
          renderer = Neos.Fusion:Array {
              @process.addTag = Carbon.IncludeAssets:TypeCase {
                isCSS.renderer = ${Configuration.setting('Carbon.IncludeAssets.LoadCSSAsynchron') && node.context.live && attributes == 'async' ? '<link rel="preload"' + value + ' as="style" onload="this.rel=\'stylesheet\'" onerror="this.rel=\'stylesheet\'" /><noscript><link rel="stylesheet"' + value + ' /></noscript>' : '<link rel="stylesheet"' + value + ' />'}
              }
          }
      }
  }

Hack, maybe because I need have in settings something like this with an async attribute: "rootAsync.css[async]". That async attribute is also added to the sylesheet link. It is quite useless, however, that works just fine.

jonnitto commented 6 years ago

Good point. I‘ll extend the package with this possibility

jonnitto commented 6 years ago

Solved with Version 2.0.0