Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile All Contrib and Custom .js Files Into a Single .js File #8

Open
signalpoint opened this issue Sep 26, 2014 · 0 comments
Open

Comments

@signalpoint
Copy link

Some apps can have lots of contrib modules and custom modules installed. Here's an example app's console.log() output during the bootstrap:

app/modules/addressfield/addressfield.js jdrupal-dev.min.js:7
app/modules/date/date.js jdrupal-dev.min.js:7
app/modules/entityreference/entityreference.js jdrupal-dev.min.js:7
app/modules/flag/flag.js jdrupal-dev.min.js:7
app/modules/fivestar/fivestar.js jdrupal-dev.min.js:7
app/modules/force_authentication/force_authentication.js jdrupal-dev.min.js:7
app/modules/link/link.js jdrupal-dev.min.js:7
app/modules/geofield/geofield.js jdrupal-dev.min.js:7
app/modules/rate/rate.js jdrupal-dev.min.js:7
app/modules/telephone/telephone.js jdrupal-dev.min.js:7
app/modules/webform/webform.js jdrupal-dev.min.js:7
app/modules/custom/my_module/my_module.js jdrupal-dev.min.js:7
themes/easystreet3/easystreet3.js

Each one of these has to be manually loaded into the DOM via a GET during the bootstrap. This definitely causes performance issues, and probably hogs more memory than necessary. It'd be great if we could optionally include a single file in the index.html file, for example:

<script type="text/javascript" "bin/drupalgap.js"></script>
<script type="text/javascript" "bin/drupalgap.aggregated.js"></script><!-- all custom/contrib modules in one file -->

So to do this we would need a command which would round up all the .js files that make up the app's custom/contrib modules, and concatenate them all into a single .js file and write it to the bin directory. For example:

dgm aggregate js

We then would need a corresponding entry for settings.js, for example:

drupalgap.settings.aggregations = {
  js: {
    enabled: true;
  },
  css: {
    enabled: false;
  }
};

Then DG core would need to be updated to skip the manual loading during the bootsrap if aggregation is turned on.

It'd be extra cool if the command could automatically add/delete the JS script inclusion from the index.html file and update the settings.js file. Maybe settings.yaml is a pre-requisite to such features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants