Minify Javascript

Minify Javascript Solution

What it is:With the increase in the use of Ajax and Javascript libraries on the websites, the loading time of the pages increases considerably. For a 25-30 kb HTML file, 80-90 kb Javascript and CSS file are used.
Solution:We can reduce file sizes by clearing the spaces and comments in our Css and Javascript files.
Expert Comment:It should be done even if it does create some difficulty in the development period.

General Explanation

The “Minifying” code means eliminating unnecessary bytes. Examples include extra spaces, line breaks, and indentation. Keeping the JavaScript code tight has some advantages. It is possible to mention that the smaller file size for inline JavaScript and external files that are not cached reduces the network latency that occurs each time a page is downloaded. Secondly, compression of external JS files and HTML files with JS code inline may increase even more. Thirdly, smaller files can be loaded and run faster by web browsers.

Various tools can be used to minimize JavaScript, including Shutdown Compiler, JS Min or YUI compressor. A build program can be created that uses these tools to shrink and rename progress files and save them to a production directory. We recommend to shrink JS files that are 4096 bytes or larger. You should see a benefit for any file that can be reduced by 25 bytes or more. (Less than this does not result in any noticeable performance gains.)

JavaScript Recommendations

You should shrink your HTML, CSS and JavaScript resources:

  • Try the HTML Minifier to minimize the HTML.
  • Try CSSNano and csso to minimize CSS.
  • Try UglifyJS to minimize JavaScript. Closing Compiler is also very effective. You can create a rendering process that uses these tools to shrink and rename development files and save them to a production directory.

Alternatively, the PageSpeed Module integrates with an Apache or Nginx web server to automatically optimize your site, including resource minification.

Making JavaScript and CSS External

Because JavaScript and CSS files are cached by the browser, using external files in the real world often results in faster pages creation. Inline JavaScript and CSS in HTML documents are downloaded whenever the HTML document is requested. Although this reduces the number of HTTP requests required, it causes an increase in the size of the HTML document. On the other hand, the external document cached by the JavaScript and CSS browser reduces the size of the HTML document without increasing the number of HTML requests.

Page Speed Terms and Solutions

Recent Articles

Russian YouTuber Has Crash (!) With Porsche Taycan Turbo S In Porsche Store

Russian YouTuber Mikhail Litvin showed in a video she recently shared with a Porsche Taycan Turbo S directly at the Porsche store. Russian YouTuber Mikhail...

Top 15 Technology Blogs for 2021

77 percent of Internet users read blogs and 23 percent of all time on the internet social networks disclose the expenditure of reading and...

Viewing Domain Records (nslookup)

Hello Media Zone Blog Readers,In this article, I will try to talk briefly and simply about the name server of the domain you have...

How to Rebuild Your Business After the COVID-19 Shutdown

The coronavirus lockdown had a devastating effect on small businesses everywhere. Even ifyou were able to adapt your business model to continue...

Computer Tech: A Secure Investment in Your Future

Choosing a career path in IT is a safe bet for a long and lucrative work life. An endless supply ofcomputer tech...

Related Stories

Your feedback is valuable to us

MediaZone - Ge the daily news in your inbox