Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice to maintain minified files and deployment/development

I'm stuck in a bit of dilemma on how to get around this and was hoping someone would point me in the right direction.

I am trying to cut down on the size of css and javascript files to improve our website's performance. But the problem is, on deployment, we simply upload our current svn repository's latest development version onto the server.

I am finding it hard to add that extra step for every developer to minify files before every change, as it adds a risk for negligence and human error.

I was thinking about having the readable version of files on the server anyway, but having some kind of file monitor that will execute a minifier when a file is changed, and update the file used by the website. Has anyone implemented this before?

EDIT

We're currently running on ASP.Net 2.0, Windows Server 2003

like image 956
Matthew Grima Avatar asked Jan 05 '12 17:01

Matthew Grima


People also ask

Does minified code run faster?

Minification does improve performance for two reasons: Reduced file-size (because it removes comments and unnecessary white spaces), so your script loads faster. Even if it is embedded into the <head> . It is parsed faster, since comments and white spaces don't have to be explicitly ignored (since they're not there).

What is a minified file?

Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience.

Does Minifying CSS improve performance?

In simple words, minification is the method of removing all the unnecessary things including whitespaces and comments from HTML, CSS, and JavaScript code that do not affect our output. It reduces the project size and improves performance.

How is minification done?

Minification works by analyzing and rewriting the text-based parts of a website to reduce its overall file size. Minification extends to scripts, style sheets, and other components that the web browser uses to render the site. Minification is performed on the web server before a response is sent.


2 Answers

If you are using .net on the server, you could also try RequestReduce available on Nuget. It minies and bundles your css and js and also sprites css background images. It does it on the fly so your devs don't have to do this as an extra step. As long as you have some kind of versioning in place that changes the css/js url when it is changed, RequestReduce will automatically detect the change and process the file. It does all of this in the background and there fore does not affect the response time. If the files are not versioned via the url, RequestProduce provides a dashboard where you can flush its cache. RequestReduce can be deployed with absolutely no code changes and hardly any config in most use cases.

like image 169
Matt Wrock Avatar answered Sep 29 '22 06:09

Matt Wrock


If you are using ASP.NET, try MBCompression library - it minify files automatically and you don't need do it manually:

like image 28
Alex Dn Avatar answered Sep 29 '22 06:09

Alex Dn