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

Minification #275

Closed
AllWorkNoPlay-95 opened this issue Jul 6, 2023 · 4 comments
Closed

Minification #275

AllWorkNoPlay-95 opened this issue Jul 6, 2023 · 4 comments

Comments

@AllWorkNoPlay-95
Copy link

Currently, the JavaScript (JS) code in our project is not minified, which can negatively impact the performance of our application. This issue aims to address the need for JS code minification and its benefits.

Problem Statement:
Unminified JavaScript code contains unnecessary whitespace, comments, and long variable/function names. While this is beneficial for developers during development and debugging, it adversely affects the performance of the application in a production environment.

Impact of Unminified JS Code:

Increased file size: Unminified JS code is larger in size due to additional formatting, comments, and lengthy variable/function names. Larger file sizes result in longer download times for users, leading to slower page loading.
Network latency: Large JS files take longer to transfer over the network, especially for users with limited bandwidth. This delay can negatively impact user experience, particularly on slower connections or mobile devices.
Parsing and execution time: Browsers need to parse and execute JS code. Unminified code with unnecessary characters and comments increases the parsing time, affecting overall application performance.
Caching: Minified JS code has a higher chance of being cached by browsers, reducing subsequent load times. Unminified code, however, may not be cached as effectively due to frequent changes during development, resulting in more requests to the server.
Proposed Solution:
To overcome these performance issues, we should minify our JavaScript code before deploying it to a production environment. Minification is a process that removes unnecessary characters such as whitespace, comments, and renames variables/functions to shorter names, without affecting their functionality.

Benefits of JS Code Minification:

Reduced file size: Minified JS code significantly reduces the file size by removing unnecessary characters, resulting in faster downloads and improved page load times.
Faster parsing and execution: Minified code is easier and faster to parse, allowing browsers to execute the code more quickly, thereby improving application performance.
Improved caching: Minified code has a higher chance of being effectively cached by browsers, reducing the number of requests made to the server and enhancing subsequent page load times.
Obfuscation: Renaming variables and functions in minified code helps to protect intellectual property and deter reverse engineering.
Implementation Steps:

Identify a JavaScript minification tool/library that suits our project's requirements (e.g., UglifyJS, Terser, Closure Compiler).
Integrate the chosen minification tool into our build process or development workflow.
Configure the minification process to remove unnecessary characters, comments, and rename variables/functions as desired.
Test the minified code in a development/staging environment to ensure it behaves correctly and does not introduce any bugs.
Update our deployment process to use the minified version of the JS code in the production environment.
Monitor application performance after minification to measure the improvements and address any potential issues.
By minifying our JavaScript code, we can significantly improve the performance of our application, reduce page load times, and enhance the overall user experience.

@morvy
Copy link
Contributor

morvy commented Jul 6, 2023

Did you use ChatGPT to write such a long issue? We all know about benefits and drawbacks AND there is a pull request for this already #261

@AllWorkNoPlay-95
Copy link
Author

AllWorkNoPlay-95 commented Jul 6, 2023

request

It's interesting that you mention it, since it's one of the first things to implement for a wordpress plugin, but I see that anyway, despite the existing issue, the work hasn't been carried forward. More motivation was needed, even if "We all know about benefits and drawbacks" of minification.

Closing it since, as you mentioned, it's a duplicate of #261.

@morvy
Copy link
Contributor

morvy commented Jul 6, 2023

It just needs some more time, Thomas had to release stable 1.17 which has a lot of improvements. I believe he's working hard when he has time for this project and I think he'll focus on removing Universal Analytics from code for example which will shrink the code significantly.

We discussed this topic here: #257 so you can give your insights there. This wasn't meant as a hate, it's just too long text for such information :)

@AllWorkNoPlay-95
Copy link
Author

Yes, i saw the gulp implementation and it looks very good!
Should be enough to fix the minification issue.
I'll pull that for now and test it, will try to fork and open a PR if needed.
Cheers!

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