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

Extend HTML compressor to compress and combine external files #92

Open
GoogleCodeExporter opened this issue Apr 12, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

Hello,

I'm compressing HTML files referencing external CSS and Javascript scripts. I 
would like to set a particular compressor to the HTMLCompressor through Java 
API that is used each time an external script is detected.

My compressor will be in charge to load the files thanks to the given paths, 
compress and combine it and then return the new path to add as external script.

API proposal:

// new interface
interface ExternalCompressor {
   String compress(List<String> path, Compressor defaultCompressor);
}

// new setter
htmlCompressor.setExternalCompressor((paths, defaultCompressor) -> {
    // implementation sample skeleton
    paths.forEach((path) -> {
        File f = new File(baseDir, path);
        String content = ...
        defaultCompressor.compress(content);
        ...
    }

    return combinedPath;
});

Result:

<html>
<head>
<link rel="bar.css" />
<script src="foo.js" />
</head>
<body>
<script src="bottom1.js" />
<script src="bottom2.js" />
</body>
</html>

// gives
<html>
<head>>
<link rel="/custom-path/bar.min.css" />
<script src="/custom-path/foo.min.js" /
</head>
<body>
<script src="/custom-path/combine.min.js" /
</body>
</html>

Thanks!



Original issue reported on code.google.com by guidro...@gmail.com on 21 Feb 2014 at 1:50

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

1 participant