A new feature for SilverStripe should be ...

Add a weighting system to Requirements

CSS and JS files are loaded in the order they are called (with some intelligence based on what requirements are called). When you have multiple modules and your core theme all calling requirements from different places sometimes requirements get called in an order that is not ideal.

My first thought on this was maybe a simple weighting system, so higher numbers float to the top, the call would look something like:

This is following on from the Github issue raised here: https://github.com/silverstripe/silverstripe-framework/issues/6454#issuecomment-271622873

9 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Morven Lewis-Everley shared this idea  ·   ·  Admin →
    declined  ·  AdminIngo Schommer (Admin, SilverStripe) responded  · 

    We’re not planning to add more sophistication to the Requirements API along those lines. It’s more common these days to compile one bundle for your project in question, through frontend tooling like Webpack. This might include module JavaScript where you can define your own order of preference.

    In the CMS, there’ll be more structured ways to extend functionality than calling Requirements::block() on a file with a bunch of Entwine rules, and then recreate your own ones.

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Michal Kleiner commented  · 

        I'd suggest instead of using weighting (or at least beside to that), would be to specify dependencies, e.g. what file requires which other files to be loaded before. Then resolve this to a chain of dependencies and load them accordingly. With weighting, it seems like the same problem again in a case when all weights are set to be the same.

      Feedback and Knowledge Base