remy / inliner

Node utility to inline images, CSS and JavaScript for a web page - useful for mobile sites
MIT License
1.1k stars 165 forks source link

Combine multiple Javascript blocks #80

Closed itmm closed 8 years ago

itmm commented 8 years ago

Thank you for sharing this project!

I would like to split my JavaScript into multiple files, to get some order into the over thousand lines of code. To keep it working in the not inlined version, I would like to add a couple of script tags like in the following example

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
        <script src="a.js"></script>
        <script src="b.js"></script>
    </body>
</html>

The result by invoking it with inliner test.html is

<!DOCTYPE html> <html> <head> <title>Test</title> </head> <body> <script>alert("in a");</script> <script>alert("in b");</script> </body> </html>

Is it possible to merge files of the same type (JS, CSS, etc.) to one file before minifying and including it? It would expect a result like

<!DOCTYPE html> <html> <head> <title>Test</title> </head> <body> <script>alert("in a");alert("in b");</script> </body> </html>

That would be great to have a structured project minified to one page.

If you can point me into the code where the needed changes have to be performed, I may gladly contribute.

Thanks again.

remy commented 8 years ago

I'm not going to implement this. The benefit is minimal compared to the complexity to actually achieve this.

Please trust that I've given this quite a bit of thought, and my initial concern was with mixing the two blocks of JS, then there's checking that they're next to each other, and then I started to consider more edge cases. I hope that's cool.