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

Feature: Filter for adding scripts that would normally be inline into minification #53

Open
Pypeline opened this issue Feb 12, 2014 · 3 comments

Comments

@Pypeline
Copy link

I've been playing around with the plugin and needed a way to get some scripts that were inline (needing to use variables from php) into the concatenated/minified js file. Working on trying to get down to 1 js and 1css file. Anyway, I added a filter in the minify function just before stuff starts getting passed to the minify libraries.

looks like this:

$contents_for_each_dep = apply_filters( 'combine_inline_sources', $contents_for_each_dep, $type );

You'd want to check for $type depending on wether you're adding scripts or styles, and then you need to add a source name (URL seems irrelevant) and the js/css to the array of sources. This "inline" stuff wouldn't show up in the list of included dependency bundles but didn't seem like a big deal.

Just wondering if this is a feature that would be wanted in the plugin. Or if I missed something and there's already a better way to do this included! I can do a pull request if you're interested.

@Pypeline
Copy link
Author

I guess I didn't consider instances where there's more than 1 minified and combined JS file, because this way would result in the extra scripts being added to each file put together by the plugin. I was focused on my use case of a single js file produced.

Still, might be something that can be done about that without much trouble.

@shadyvb
Copy link
Contributor

shadyvb commented Feb 13, 2014

I'm not sure if this would be a generically needed feature, since it'd invalidate the whole cached file if any inline script/css changes slightly. And I'm seeing little benefit of doing so, since for caching, this should be taken care of by page cache if activated, and for minification, there would be much less benefit since normally inline styles/scripts shouldn't be that big, also it'd be taken care of by HTML minifying/caching plugins.

@Pypeline
Copy link
Author

Good point, thanks for the feedback.

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

No branches or pull requests

2 participants