Coder Social home page Coder Social logo

rcompressor's Introduction

RCompressor

RCompressor

A compressor for Razor Views.

Help me! Improve this translation with a pull request.

or see previous versions.

Summary

Introduction

Have you ever thought that the generated HTML from a .cshtml file is not optimized?

Take a look at the below code which is the content of a simple _Layout.cshtml file:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - WebApplication6</title>
</head>
<body>
    <div>
        @RenderBody()
        <footer>MyWebApplication</footer>
    </div>
    @RenderSection("Scripts", required: false)
</body>
</html>

And the below code is the content of a simple Index.cshtml file:

@{
    ViewData["Title"] = "Home Page";
}
<div class="row">
    <h1>This the Index page</h1>
</div>

When you visit the page through the browser, the generated HTML is:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Home Page - WebApplication6</title>
</head>
<body>
    <div>
        <div class="row">
    <h1>This the Index page</h1>
</div>
        <footer>MyWebApplication</footer>
    </div>
    
</body>
</html>

How many spaces and empty new lines!

The response size is 650B. This is not a problem if the page is small, but think about bigger pages.

Using RCompressor, you can strip out the code from spaces, empty lines, and comments.

Processing the previous .cshtml files with RCompressor the response size becomes 604B, which is ~8% smaller. You can save a lot of bytes in bigger files.

How to use

  • Download the latest version of RCompressor and launch it (no installation required);
  • paste the directory/file path in the first field;
  • check the Scan subfolders option if required;
  • press the Compress button.

Command line usage

You can use RCompressor using the command line by passing the paths as parameters.

Add the -subfolders option to scan subfolders.

Usage example:

> RCompressor.exe -subfolders "C:\MyDir" "C:\MyFile.cshtml"

RCompressor will compress all .cshtml files inside C:\MyDir and subfolders. It will also compress the C:\MyFile.cshtml file.

rcompressor's People

Contributors

omaxel avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

mrahla

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.