Y
Y
Yuri Yerusalimsky2017-06-24 23:45:53
JavaScript
Yuri Yerusalimsky, 2017-06-24 23:45:53

How to increase the compression of JS code without violating the appearance (readability)?

According to Google PageSpeed ​​Insights, you need to compress JS code. In principle, I agree to this, taking into account the option that the readability of the text will not be violated, that is, the entire code will not turn into one continuous line of characters. In any case, I know that CSS optimizers allow you to work in modes where styles are optimized in one line, one line per style, or one block per style. Yes, this is not exactly the same, but the principle that I'm looking for is the absence of a violation of style, maximum, optimization of writing code, reduction of some expressions. Is there anything, in the form of an online service or a GUI application?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Demian Smith, 2017-06-25
@werber

I understand that you have not yet figured out how to use the version control system. Hence the desire to put uncompressed files on a server so as not to lose them. Nobody does that because it's a recipe for failure. How they do it:
1. All code is stored in the version control system (GIT). Think of it as the file storage of your project, to which any developer has access
2. Before uploading the code to the server, it is run through a program that compresses and glues all the javascript and css into one file. Usually this step is automated. In your case, I would start doing this routine with my hands until I get bored and want to automate it using, for example, Gulp.
Here you can register and create a private GIT repository for your project: https://bitbucket.org/,and then put project files in it. After you register and create a GIT repository (by the way, in git terms, the repository is called a "repository"), you will have a link to this repository. This link is the address where the working files of your project are stored. For other project participants (developers, customers, testers), the project's git repository is even more important than the files on the server. Because usually only a select few have access to the files on the server, and all participants should have access to the project files.

F
Fixid, 2017-06-24
@Fixid

What's stopping you from uploading only the most optimized version to the server? Who needs this style? The browser doesn't care. If you want to debug JS directly on the prod, then this is a bad idea.

A
Anton, 2017-06-24
@SPAHI4

Source codes are usually stored in a git repository.
Already minified files are uploaded to production. If you need debugging in production, there are sourcemaps.
And, yes, everything is usually automated.

N
Nikita Kit, 2017-06-25
@ShadowOfCasper

All the same, the entire front-end is sawn locally. I use gulp with tasks that minified js, css + sourcemaps are built for me in build - I upload everything that I compile in build to the server using a small git hack. Rather hook. Or rather, a couple of hooks (googled "git and publishing the site"). And the source code remains local. Unminified and readable. No interface changes on the server - we are not in 2007. If you need edits -
edit on gulp serve, then - gulp build && cd build && git add . && git commit -m 'cy4u praBku' && git push hub master , let's go enjoy our mojito))

Y
Yuri Yerusalimsky, 2017-06-24
@werber

I had such an idea to fill in two versions, if it really happened - a minimalized one, and a regular one, with the original_ prefix. To store the normal version somewhere if edits are required.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question