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

Combine JS files using jsmin-php #581

Open
TheoChevalier opened this issue Jan 5, 2016 · 4 comments
Open

Combine JS files using jsmin-php #581

TheoChevalier opened this issue Jan 5, 2016 · 4 comments

Comments

@TheoChevalier
Copy link
Member

Currently, each time we’re adding a JS library, we’re adding a new resource (so a new HTTP request). We might want to combine all of our JS file into a single one and we could use jsmin-php for that ( http://stackoverflow.com/questions/868857/combining-and-compressing-multiple-javascript-files-in-php )

We could also cache the generated file to avoid impacting the process time.

@flodolo
Copy link
Collaborator

flodolo commented Jan 5, 2016

Actually, the point of having separate files is to avoid loading JavaScript code in the browser when it's not needed.

Unless you plan to support that directly in the code (e.g. load the suggestions code only if there's a search bar, etc.), I don't see any advantage in merging and compressing: we improve load time and number of requests, but make the page heavier.

@TheoChevalier
Copy link
Member Author

The file would be generated dynamically, from the list of JS files to load for a given view, we would not create a single JS file containing all the other files for all pages.

@pascalchevrel
Copy link
Member

I think it's a good idea but the thing I don't like about minification is that it makes debugging harder, it would be good to have the js files combined only for production.

@TheoChevalier
Copy link
Member Author

Indeed. Also, jsmin-php seems unmaintained, we should use something else, like https://github.com/tedious/JShrink#composer

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

3 participants