Giter Site home page Giter Site logo

microsoft / ajaxmin Goto Github PK

View Code? Open in Web Editor NEW
29.0 6.0 19.0 2.34 MB

The Microsoft Ajax Minifier enables you to improve the performance of your Ajax applications by reducing the size of your Cascading Style Sheet and JavaScript files.

Home Page: https://www.nuget.org/packages/AjaxMin

License: MIT License

C# 91.70% Batchfile 0.01% Smalltalk 0.04% PowerShell 0.05% CSS 1.62% JavaScript 6.57%

ajaxmin's Introduction

⚠️ Notice: This project is no longer maintained.

Project Description

The Microsoft Ajax Minifier enables you to improve the performance of your web applications by reducing the size of your Cascading Style Sheet and JavaScript files.

Minify both JS and CSS files, and now optionally produce Source Maps for JavaScript files.

Use the -analyze option on the command-line to provide lint-style syntax checking and variable analysis of your code.

Use the -pretty option on the command-line to output in a nice, easy-to-read multi-line format (good for un-minifying minified code).

JavaScript and CSS files minified with Ajax Minifier should work as-is; you shouldn’t have to do anything special in your code to get good results. If your file doesn’t work after minification, first check to see if your JavaScript code contains eval statements that might require you to use a different –evals switch. If your file still doesn’t work, please file a report on the “Issue” page so I can get Ajax Minifier fixed.

If you have any new feature requests, please feel free to bring them up on the "Issues" page. We cannot guarantee feature requests will make it into the code.

Offical NuGet Package

There is an official NuGet package for the DLL version of Microsoft Ajax Minifier, if you prefer to manage your C# projects in that manner:

http://nuget.org/packages/AjaxMin

AjaxMin was created by Ron Logan.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

ajaxmin's People

Contributors

microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar seankeating avatar sekeatin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ajaxmin's Issues

2 variables in scope given same name

I installed from nuget in Visual studio [version: 5.14.5506.26196, runtime version: v4.0.30319]

and used
Dim jsMinifier As New Minifier
Dim minifiedCode As String = jsMinifier.MinifyJavaScript(unminifiedCode)

and it minified the following snippet:

addColumns(cols) {
for (let col of cols) {
let colControl = new ColumnReordererRow(this, col);
this.columnArea.add(colControl.getComponent());
}
}

as

addColumns(n){for(let n of n){let t=new ColumnReordererRow(this,n);this.columnArea.add(t.getComponent())}}

both col and cols have been renamed as "n" which of course doesn't work!

Does Ajaxmin support removal of dead code?

In various projects I have worked on, developers leave a lot of dead code in the comments mostly for debugging purposes, however that code get's transported and it does not get removed... Before writing here, I came across this issue with @Taritsyn of the WebMarkUpMin project as well as NUglify JS minifer project. Does ajaxmin support removing dead code -- the 'if (false' statements)?

How does it work?

The docs are from 2009 and I'm interested in generating map files. Can you add something to the readme?

Is there a .NET Core 6 version?

Hello.... I know this project is quiet old. When using in a .NET Core 6 project a warning is shown telling that this project is for .NET Framework (until 4.8 version). Have you planned to upload a .NET Core version or do you know about an alternative?

Thanks
Jaime

CSS variables fail to minify on Publish

If you have global variables in the css: i.e.:

    --mainBackground: linear-gradient(135deg, #f6fcff 0%,#e8ebee 2%,#fafafa 47%,#f6fcff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
    --darkDropShadow: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
    --popupMenuShadow: 0 0 24px -4px rgba(0,0,0,0.75);
    --MenuBoxShadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}

Then the project will fail to publish because it does not recognise the '--' characters. It expects a semicolon.

`??` operator leads to crash

Using the ?? operator inside JavaScript leads to a crash with a NullReferenceException. The full stack trace is as follows:

[NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.]
   Microsoft.Ajax.Utilities.JSParser.ParseExpression(AstNode leftHandSide, Boolean single, Boolean bCanAssign, JSToken inToken) +820
   Microsoft.Ajax.Utilities.JSParser.ParseExpression(AstNode leftHandSide, Boolean single, Boolean bCanAssign, JSToken inToken) +654
   Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(Boolean isMinus) +2360
   Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus) +1090
   Microsoft.Ajax.Utilities.JSParser.ParseExpression(AstNode leftHandSide, Boolean single, Boolean bCanAssign, JSToken inToken) +620
   Microsoft.Ajax.Utilities.JSParser.ParseExpressionStatement(Boolean fSourceElement) +147
   Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +1474
   Microsoft.Ajax.Utilities.JSParser.ParseFunctionBody(Block body) +43
   Microsoft.Ajax.Utilities.JSParser.ParseFunction(FunctionType functionType, Context fncCtx) +1077
   Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +905
   Microsoft.Ajax.Utilities.JSParser.ParseFunctionBody(Block body) +43
   Microsoft.Ajax.Utilities.JSParser.ParseFunction(FunctionType functionType, Context fncCtx) +1077
   Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(Boolean isMinus) +2626
   Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus) +1090
   Microsoft.Ajax.Utilities.JSParser.ParseExpressionList(JSToken terminator) +408
   Microsoft.Ajax.Utilities.JSParser.ParseMemberExpression(AstNode expression, List`1 newContexts) +106
   Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(Boolean isMinus) +3074
   Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus) +1090
   Microsoft.Ajax.Utilities.JSParser.ParseExpressionStatement(Boolean fSourceElement) +41
   Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean fSourceElement, Boolean skipImportantComment) +1474
   Microsoft.Ajax.Utilities.JSParser.ParseStatements(Block block) +76
   Microsoft.Ajax.Utilities.JSParser.InternalParse() +830
   Microsoft.Ajax.Utilities.Minifier.MinifyJavaScript(String source, CodeSettings codeSettings) +805
   System.Web.Optimization.JsMinify.Process(BundleContext context, BundleResponse response) +115
   System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable`1 bundleFiles) +325
   System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) +59
   System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath) +213
   System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets) +421
   System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) +34
   ASP._Page_Views_Work_Index_cshtml.Execute() in C:\dev\DE.ZA.TrailerLoading\DE.ZA.TrailerLoadingAssistant.Web\Views\Work\Index.cshtml:153
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +86
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +91
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +43
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +651
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134

Got object reference null issue when resolve the js file

We have added a ScriptBundle of js file, and got exception

  bundles.Add(new ScriptBundle("~/admin/js").Include("js file path");

System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Ajax.Utilities.Member.GetFunctionGuess(AstNode target)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.GuessAtName(AstNode node)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(FunctionObject node)
at Microsoft.Ajax.Utilities.FunctionObject.Accept(IVisitor visitor)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(BinaryOperator node)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node)
at Microsoft.Ajax.Utilities.TreeVisitor.Visit(IfNode node)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(IfNode node)
at Microsoft.Ajax.Utilities.IfNode.Accept(IVisitor visitor)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node)
at Microsoft.Ajax.Utilities.TreeVisitor.Visit(IfNode node)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(IfNode node)
at Microsoft.Ajax.Utilities.IfNode.Accept(IVisitor visitor)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node)
at Microsoft.Ajax.Utilities.TreeVisitor.Visit(IfNode node)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(IfNode node)
at Microsoft.Ajax.Utilities.IfNode.Accept(IVisitor visitor)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(FunctionObject node)
at Microsoft.Ajax.Utilities.FunctionObject.Accept(IVisitor visitor)
at Microsoft.Ajax.Utilities.TreeVisitor.Visit(CallNode node)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(CallNode node)
at Microsoft.Ajax.Utilities.CallNode.Accept(IVisitor visitor)
at Microsoft.Ajax.Utilities.AnalyzeNodeVisitor.Visit(Block node)
at Microsoft.Ajax.Utilities.JSParser.InternalParse()
at Microsoft.Ajax.Utilities.Minifier.MinifyJavaScript(String source, CodeSettings codeSettings)
at System.Web.Optimization.JsMinify.Process(BundleContext context, BundleResponse response)
at System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable1 bundleFiles) at System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) at System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath) at System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable1 refs)
at System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths)
at ASP._Page_Views_Shared__AdminLayout_cshtml.Execute() in
_AdminLayout.cshtml:line 29
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.WebPages.WebPageBase.<>c__DisplayClass40_0.b__0(TextWriter writer)
at System.Web.WebPages.WebPageBase.Write(HelperResult result)
at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) at System.Web.WebPages.WebPageBase.PopContext() at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.b__1(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<>c.b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<>c.b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

The file was downloaded from https://datatables.net/download/index

datatables.min.js.zip

Computed property name brakes minifier...

Hi,
When I'm using computed property names to create object, the minified version is totally broken...

Original:
var i = 0; var a = { ['foo' + ++i]: i, ['foo' + ++i]: i, ['foo' + ++i]: i };

Minified
var i=0,a={}["foo"+ ++i];i;["foo"+ ++i];i;["foo"+ ++i];i

I'm using version 5.14.5506.26202 (latest for now)...

An executable file in the repository

We are using a command line AjaxMin.exe tool (version 4.45.4416.14250) in our solution. It's used as one of the MSBuild tasks defined in our project file. Currently we are migrating our project from .NET Framework 3.5 version to .NET Framework 4.6.

The problem we have is that AjaxMin.exe command doesn't work on the environment without 3.5 .NET Framework installed.

We tried to generate an executable file from AjaxMin solution from repo. We generated our own .snk file and built. But the output .exe file is still not working without .NET Framework 3.5. Our output .exe file has 5.15.6851.30012 version. The error we got:

The command "AjaxMinifier.exe -JS -comments:none -rename:none -clobber -xml AjaxMin-full-paths.xml" exited with code 1.

I wonder if it's possible that you push .exe file to the repo? Or maybe an installer file? I can see that it was hosted on CodePlex site before.

Then we could check if it's a problem with the way we are building .exe file or maybe this tool in fact requires .NET Framework 3.5 to be installed.

Thank you,
Adrian

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.