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

Improve the JavaScript and CSS loading adding minified versions #842

Closed
YordanSoares opened this issue Jun 1, 2022 · 3 comments
Closed

Comments

@YordanSoares
Copy link
Contributor

Currently, Contact Form 7 load the JavaScript and CSS files without minification. It would be a good enhancement to also provide minified versions of the JavaScripts and CSS assets, and load these versions by default, but allowing to load unminified version if the SCRIPT_DEBUG constant is set.

Related topic about this in the support forum at WordPress.org:
https://wordpress.org/support/topic/unminified-javascript-and-css-files-3/

@takayukister
Copy link
Collaborator

Are you saying about admin scripts? If so, the JS will be minimized in 5.7.

I don't think minimizing CSS can make meaningful differences.

@YordanSoares
Copy link
Contributor Author

Are you saying about admin scripts?

That's right. I also thought it could be great to include unminified versions following the proposal above, serving the right version based on the SCRIPT_DEBUG constant.

I mean something like this:

$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

wp_enqueue_style( 'contact-form-7-admin',
	wpcf7_plugin_url( 'admin/css/styles' . $suffix . '.css' ),
	array(), WPCF7_VERSION, 'all'
);

if ( wpcf7_is_rtl() ) {
	wp_enqueue_style( 'contact-form-7-admin-rtl',
		wpcf7_plugin_url( 'admin/css/styles-rtl' . $suffix . '.css' ),
		array(), WPCF7_VERSION, 'all'
	);
}

wp_enqueue_script( 'wpcf7-admin',
	wpcf7_plugin_url( 'admin/js/scripts' . $suffix . '.js' ),
	array( 'jquery', 'jquery-ui-tabs' ),
	WPCF7_VERSION, true
);

Repeating the same approach in all the relevant areas, like submodules, backend, etc. What do you think?

I don't think minimizing CSS can make meaningful differences.

However, it won't hurt! This will allow passing the warnings from performance scans that make users ask about it over and over again.

@takayukister
Copy link
Collaborator

This has been fixed in #1464

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