https://github.com/omaxel/rcompressor
A compressor for Razor Views.
https://github.com/omaxel/rcompressor
aspnet-core-mvc aspnet-mvc compressor optimization optimization-tools razor razor-views
Last synced: 8 months ago
JSON representation
A compressor for Razor Views.
- Host: GitHub
- URL: https://github.com/omaxel/rcompressor
- Owner: omaxel
- Created: 2018-04-06T07:30:26.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-11T08:03:12.000Z (over 4 years ago)
- Last Synced: 2025-01-20T16:00:01.560Z (about 1 year ago)
- Topics: aspnet-core-mvc, aspnet-mvc, compressor, optimization, optimization-tools, razor, razor-views
- Language: C#
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# RCompressor
A compressor for Razor Views.
**Help me!** Improve this translation with a pull request.
### [Download latest version](https://github.com/OmarMuscatello/RCompressor/releases/download/v1.0/RCompressor-v1.0.zip)
or see [previous versions](https://github.com/OmarMuscatello/RCompressor/releases).
##### Summary
- [Introduction](#introduction)
- [How to use](#how-to-use)
- [Command line usage](#command-line-usage)
## 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:
```
@ViewData["Title"] - WebApplication6
@RenderBody()
MyWebApplication
@RenderSection("Scripts", required: false)
```
And the below code is the content of a simple `Index.cshtml` file:
```
@{
ViewData["Title"] = "Home Page";
}
This the Index page
```
When you visit the page through the browser, the generated HTML is:
```
Home Page - WebApplication6
This the Index page
MyWebApplication
```
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](https://github.com/OmarMuscatello/RCompressor/releases/download/v1.0/RCompressor-v1.0.zip) 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.