SlideShare ist ein Scribd-Unternehmen logo
1 von 29
ASP.NET Web Optimization withCOMBRES Buu Nguyen
Buu Nguyen Director of Technology, KMS Technology, www.kms-technology.com Lecturer, RMIT Vietnam, www.rmit.edu.vn www.buunguyen.net/blog Twitter: buunguyen
Combres optimizes your web apps by combining,minifying,compressing, caching, and enhancingCSS & JavaScript resources before sending them to browser
Agenda Combres Overview Beyond Simple Usage Filtering Architecture Minification Architecture Future Direction Appendix – Combres Quickly
Life Without Combres
Define Combres Resource Sets
HTTP Response Combine, Cache, Compress Original CSS size is 33KB – a 85% size decrease Minify
Beyond Simple Usages
A Couple of Issues
Updated Combres Data File
Auto-Versioning You’ve just seen auto-versioning in action Automatically detects changes to Addition/removal of resources in a set Contents of static/dynamic resources  Applied filters & their parameters Applied minifier & its parameters Can switch version generation algorithm Turn-on once, and never have to touch the data file to modify version again
Filtering Architecture
Intercept Combres Pipeline Read Resource Filter Filter Filter Filter Filter Filter Filter Filter invokes Combine Resources invokes Minify Combination invokes Compress Combination invokes
CSS-Variable Filter @define { background: #5c87b2; font-family: Verdana,Helvetica,Sans-Serif; } body { background-color: @background; font-family: @font-family;  font-size: .75em; } /** more CSS... **/ body { background-color: #5c87b2; font-family: Verdana,Helvetica,Sans-Serif;  font-size: .75em; } /** more CSS... **/
publicsealedclassHandleCssVariablesFilter : ISingleContentFilter { ///<inheritdoccref="IContentFilter.CanApplyTo" /> publicboolCanApplyTo(ResourceTyperesourceType)     { returnresourceType == ResourceType.CSS;     } ///<inheritdoccref="ISingleContentFilter.TransformContent" /> publicstringTransformContent(Settingssettings, Resourceresource, string content)     { if (!CanApplyTo(resource.ParentSet.Type)) thrownewArgumentException("Filter can't be applied to " +  resource.ParentSet.Type); // Remove comments because they may mess up the result         content = Regex.Replace(content, @"/.*?/", string.Empty,  RegexOptions.Singleline); varregex = newRegex(@"@define*{(?<define>.*?)}", RegexOptions.Singleline); var match = regex.Match(content); if (!match.Success) return content; var value = match.Groups["define"].Value; var variables = value.Split(';'); varsb = newStringBuilder(content); variables.ToList().ForEach(variable =>                       { if (string.IsNullOrEmpty(variable.Trim())) return; var pair = variable.Split(':'); sb.Replace("@" + pair[0].Trim(), pair[1].Trim());                       }); // Remove the variables declaration, it's not needed in the final output sb.Replace(match.ToString(), string.Empty); returnsb.ToString();     } }
Minification Architecture
Minification By default, .NET YUI Compressor library is used for JS & CSS minification Alternative built-in minifiers Google Closure (JS only) MS Ajax Minifier (JS only) It’s also possible to add your own minifier
Built-in Minifiers <cssMinifiers>   <minifiername="yui"type="Combres.Minifiers.YuiCssMinifier, Combres">     <paramname="CssCompressionType"type="string"value="StockYuiCompressor" />     <paramname="ColumnWidth"type="int"value="-1" />   </minifier> </cssMinifiers> <jsMinifiers>   <minifiername="yui"type="Combres.Minifiers.YuiJSMinifier, Combres">     <paramname="IsVerboseLogging"type="bool"value="false" />     <paramname="IsObfuscateJavascript"type="bool"value="true" />     <paramname="PreserveAllSemicolons"type="bool"value="false" />     <paramname="DisableOptimizations"type="bool"value="false" />     <paramname="LineBreakPosition"type="int"value="-1" />   </minifier>   <minifiername="msajax"type="Combres.Minifiers.MSAjaxJSMinifier, Combres" binderType="Combres.Binders.SimpleObjectBinder, Combres">     <paramname="CollapseToLiteral"type="bool"value="true" />     <paramname="EvalsAreSafe"type="bool"value="true" />     <paramname="LocalRenaming"type="Microsoft.Ajax.Utilities.LocalRenaming, ajaxmin" value="CrunchAll" />     <paramname="OutputMode"type="Microsoft.Ajax.Utilities.OutputMode, ajaxmin"            value="SingleLine" />     <paramname="RemoveUnneededCode"type="bool"value="true" />     <paramname="StripDebugStatements"type="bool"value="true" />   </minifier>   <minifiername="closure"type="Combres.Minifiers.ClosureJSMinifier, Combres">     <paramname="ApiUrl"type="string" value="http://closure-compiler.appspot.com/compile" />     <paramname="CompilationLevel"type="string"value="ADVANCED_OPTIMIZATIONS" />   </minifier> </jsMinifiers>
Using Minifiers
///<summary> /// CSS minifier which delegates the minification process to the /// YUI Compressor library (http://yuicompressor.codeplex.com/). ///</summary> publicsealedclassYuiCssMinifier : IResourceMinifier, IParametersReceiver { ///<inheritdoccref="IParametersReceiver.Binder" /> publicIObjectBinder Binder { get; set; } ///<inheritdoccref="IParametersReceiver.Parameters" /> publicIList<XElement> Parameters { get; set; } publicstringCssCompressionType { get; set; } publicint? ColumnWidth { get; set; } ///<inheritdoccref="IResourceMinifier.Minify" /> publicstring Minify(Settingssettings, ResourceSetrs,  stringcombinedContent)     { Binder.Bind(Parameters, this); var type = (CssCompressionType)CssCompressionType.ConvertToType( typeof(CssCompressionType),  Yahoo.Yui.Compressor.CssCompressionType.StockYuiCompressor); returnCssCompressor.Compress(combinedContent,  ColumnWidth == null ? -1 : ColumnWidth.Value,             type);     } }
Future Direction
Future Direction Pluggable cache provider Velocity, DB Filter to support CSS expression Pipeline optimization Allow disable compression Idea?  Bug?  Feature?  Contribution? http://combres.codeplex.com/Thread/List.aspx http://combres.codeplex.com/WorkItem/List.aspx http://combres.codeplex.com/SourceControl/UploadPatch.aspx
Download Combres 1.2 http://combres.codeplex.com Download include Binary (.NET 3.5) and referenced libraries Source code & CHM doc Sample code Sample data files (with annotation) Licensed under Apache 2.0
Appendix - Combres Quickly
Step 1. Add References Red: required DLLs Blue: optional DLLs
Step 2. Modify web.config
Step 3. Create Combres Data File
Step 4. Register Route in global.ascx
Step 5. Link to Resource Sets

Weitere ähnliche Inhalte

Was ist angesagt?

Using correlation in loadrunner 80
Using correlation in loadrunner 80Using correlation in loadrunner 80
Using correlation in loadrunner 80medsherb
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Vysakh Sreenivasan
 
Apache Camel - WJax 2008
Apache Camel - WJax 2008Apache Camel - WJax 2008
Apache Camel - WJax 2008inovex GmbH
 
Creating native apps with WordPress
Creating native apps with WordPressCreating native apps with WordPress
Creating native apps with WordPressMarko Heijnen
 
Form validation client side
Form validation client side Form validation client side
Form validation client side Mudasir Syed
 
RSpec and Rails
RSpec and RailsRSpec and Rails
RSpec and RailsAlan Hecht
 
Ruby on Rails testing with Rspec
Ruby on Rails testing with RspecRuby on Rails testing with Rspec
Ruby on Rails testing with RspecBunlong Van
 
Template Toolkit
Template ToolkitTemplate Toolkit
Template Toolkitdwm042
 
Rails 3 generators
Rails 3 generatorsRails 3 generators
Rails 3 generatorsjoshsmoore
 
Form validation server side
Form validation server side Form validation server side
Form validation server side Mudasir Syed
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusIgnacio Martín
 
Haml & Sass presentation
Haml & Sass presentationHaml & Sass presentation
Haml & Sass presentationbryanbibat
 
iOS best practices
iOS best practicesiOS best practices
iOS best practicesMaxim Vialyx
 
W2Tags Is Haml In Erb
W2Tags Is Haml In ErbW2Tags Is Haml In Erb
W2Tags Is Haml In Erbwidi harsojo
 

Was ist angesagt? (20)

JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
Using correlation in loadrunner 80
Using correlation in loadrunner 80Using correlation in loadrunner 80
Using correlation in loadrunner 80
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)
 
Apache Camel - WJax 2008
Apache Camel - WJax 2008Apache Camel - WJax 2008
Apache Camel - WJax 2008
 
Creating native apps with WordPress
Creating native apps with WordPressCreating native apps with WordPress
Creating native apps with WordPress
 
Form validation client side
Form validation client side Form validation client side
Form validation client side
 
RSpec and Rails
RSpec and RailsRSpec and Rails
RSpec and Rails
 
Prototype js
Prototype jsPrototype js
Prototype js
 
Ruby on Rails testing with Rspec
Ruby on Rails testing with RspecRuby on Rails testing with Rspec
Ruby on Rails testing with Rspec
 
Java script basics
Java script basicsJava script basics
Java script basics
 
Template Toolkit
Template ToolkitTemplate Toolkit
Template Toolkit
 
Rails 3 generators
Rails 3 generatorsRails 3 generators
Rails 3 generators
 
JSP custom tags
JSP custom tagsJSP custom tags
JSP custom tags
 
Form validation server side
Form validation server side Form validation server side
Form validation server side
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - Limenius
 
Ember - introduction
Ember - introductionEmber - introduction
Ember - introduction
 
Haml & Sass presentation
Haml & Sass presentationHaml & Sass presentation
Haml & Sass presentation
 
iOS best practices
iOS best practicesiOS best practices
iOS best practices
 
W2Tags Is Haml In Erb
W2Tags Is Haml In ErbW2Tags Is Haml In Erb
W2Tags Is Haml In Erb
 
Grails basics part2
Grails basics  part2Grails basics  part2
Grails basics part2
 

Ähnlich wie Combres

Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...Javeline B.V.
 
Struts2
Struts2Struts2
Struts2yuvalb
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
Krazykoder struts2 plugins
Krazykoder struts2 pluginsKrazykoder struts2 plugins
Krazykoder struts2 pluginsKrazy Koder
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To LampAmzad Hossain
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPStephan Schmidt
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functionsmussawir20
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSCarol McDonald
 
Flex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 FinalFlex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 Finalematrix
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introductionTomi Juhola
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP yucefmerhi
 

Ähnlich wie Combres (20)

Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...Beholding the giant pyramid of application development; why Ajax applications...
Beholding the giant pyramid of application development; why Ajax applications...
 
Struts2
Struts2Struts2
Struts2
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Riding Apache Camel
Riding Apache CamelRiding Apache Camel
Riding Apache Camel
 
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Krazykoder struts2 plugins
Krazykoder struts2 pluginsKrazykoder struts2 plugins
Krazykoder struts2 plugins
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHP
 
Spring Capitulo 05
Spring Capitulo 05Spring Capitulo 05
Spring Capitulo 05
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
 
Interoperable Web Services with JAX-WS
Interoperable Web Services with JAX-WSInteroperable Web Services with JAX-WS
Interoperable Web Services with JAX-WS
 
2 Asp Dot Net Ajax Extensions
2 Asp Dot Net Ajax Extensions2 Asp Dot Net Ajax Extensions
2 Asp Dot Net Ajax Extensions
 
DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8
 
Flex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 FinalFlex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 Final
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
 
Sencha Touch Intro
Sencha Touch IntroSencha Touch Intro
Sencha Touch Intro
 
Php
PhpPhp
Php
 

Mehr von Buu Nguyen

On Becoming a Technical Lead
On Becoming a Technical LeadOn Becoming a Technical Lead
On Becoming a Technical LeadBuu Nguyen
 
C# 3.0 and 4.0
C# 3.0 and 4.0C# 3.0 and 4.0
C# 3.0 and 4.0Buu Nguyen
 
Stories about KMS Technology
Stories about KMS TechnologyStories about KMS Technology
Stories about KMS TechnologyBuu Nguyen
 
Dynamic Binding in C# 4.0
Dynamic Binding in C# 4.0Dynamic Binding in C# 4.0
Dynamic Binding in C# 4.0Buu Nguyen
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0ASP.NET MVC 2.0
ASP.NET MVC 2.0Buu Nguyen
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuu Nguyen
 
New Features of ASP.NET 4.0
New Features of ASP.NET 4.0New Features of ASP.NET 4.0
New Features of ASP.NET 4.0Buu Nguyen
 
C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0Buu Nguyen
 

Mehr von Buu Nguyen (11)

On Becoming a Technical Lead
On Becoming a Technical LeadOn Becoming a Technical Lead
On Becoming a Technical Lead
 
C# 3.0 and 4.0
C# 3.0 and 4.0C# 3.0 and 4.0
C# 3.0 and 4.0
 
Stories about KMS Technology
Stories about KMS TechnologyStories about KMS Technology
Stories about KMS Technology
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
HTML5 in IE9
HTML5 in IE9HTML5 in IE9
HTML5 in IE9
 
Dynamic Binding in C# 4.0
Dynamic Binding in C# 4.0Dynamic Binding in C# 4.0
Dynamic Binding in C# 4.0
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0ASP.NET MVC 2.0
ASP.NET MVC 2.0
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web Applications
 
New Features of ASP.NET 4.0
New Features of ASP.NET 4.0New Features of ASP.NET 4.0
New Features of ASP.NET 4.0
 
C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0C# 4.0 and .NET 4.0
C# 4.0 and .NET 4.0
 
Fasterflect
FasterflectFasterflect
Fasterflect
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Combres

  • 1. ASP.NET Web Optimization withCOMBRES Buu Nguyen
  • 2. Buu Nguyen Director of Technology, KMS Technology, www.kms-technology.com Lecturer, RMIT Vietnam, www.rmit.edu.vn www.buunguyen.net/blog Twitter: buunguyen
  • 3. Combres optimizes your web apps by combining,minifying,compressing, caching, and enhancingCSS & JavaScript resources before sending them to browser
  • 4. Agenda Combres Overview Beyond Simple Usage Filtering Architecture Minification Architecture Future Direction Appendix – Combres Quickly
  • 7. HTTP Response Combine, Cache, Compress Original CSS size is 33KB – a 85% size decrease Minify
  • 9. A Couple of Issues
  • 11. Auto-Versioning You’ve just seen auto-versioning in action Automatically detects changes to Addition/removal of resources in a set Contents of static/dynamic resources Applied filters & their parameters Applied minifier & its parameters Can switch version generation algorithm Turn-on once, and never have to touch the data file to modify version again
  • 13. Intercept Combres Pipeline Read Resource Filter Filter Filter Filter Filter Filter Filter Filter invokes Combine Resources invokes Minify Combination invokes Compress Combination invokes
  • 14. CSS-Variable Filter @define { background: #5c87b2; font-family: Verdana,Helvetica,Sans-Serif; } body { background-color: @background; font-family: @font-family; font-size: .75em; } /** more CSS... **/ body { background-color: #5c87b2; font-family: Verdana,Helvetica,Sans-Serif; font-size: .75em; } /** more CSS... **/
  • 15. publicsealedclassHandleCssVariablesFilter : ISingleContentFilter { ///<inheritdoccref="IContentFilter.CanApplyTo" /> publicboolCanApplyTo(ResourceTyperesourceType) { returnresourceType == ResourceType.CSS; } ///<inheritdoccref="ISingleContentFilter.TransformContent" /> publicstringTransformContent(Settingssettings, Resourceresource, string content) { if (!CanApplyTo(resource.ParentSet.Type)) thrownewArgumentException("Filter can't be applied to " + resource.ParentSet.Type); // Remove comments because they may mess up the result content = Regex.Replace(content, @"/.*?/", string.Empty, RegexOptions.Singleline); varregex = newRegex(@"@define*{(?<define>.*?)}", RegexOptions.Singleline); var match = regex.Match(content); if (!match.Success) return content; var value = match.Groups["define"].Value; var variables = value.Split(';'); varsb = newStringBuilder(content); variables.ToList().ForEach(variable => { if (string.IsNullOrEmpty(variable.Trim())) return; var pair = variable.Split(':'); sb.Replace("@" + pair[0].Trim(), pair[1].Trim()); }); // Remove the variables declaration, it's not needed in the final output sb.Replace(match.ToString(), string.Empty); returnsb.ToString(); } }
  • 17. Minification By default, .NET YUI Compressor library is used for JS & CSS minification Alternative built-in minifiers Google Closure (JS only) MS Ajax Minifier (JS only) It’s also possible to add your own minifier
  • 18. Built-in Minifiers <cssMinifiers> <minifiername="yui"type="Combres.Minifiers.YuiCssMinifier, Combres"> <paramname="CssCompressionType"type="string"value="StockYuiCompressor" /> <paramname="ColumnWidth"type="int"value="-1" /> </minifier> </cssMinifiers> <jsMinifiers> <minifiername="yui"type="Combres.Minifiers.YuiJSMinifier, Combres"> <paramname="IsVerboseLogging"type="bool"value="false" /> <paramname="IsObfuscateJavascript"type="bool"value="true" /> <paramname="PreserveAllSemicolons"type="bool"value="false" /> <paramname="DisableOptimizations"type="bool"value="false" /> <paramname="LineBreakPosition"type="int"value="-1" /> </minifier> <minifiername="msajax"type="Combres.Minifiers.MSAjaxJSMinifier, Combres" binderType="Combres.Binders.SimpleObjectBinder, Combres"> <paramname="CollapseToLiteral"type="bool"value="true" /> <paramname="EvalsAreSafe"type="bool"value="true" /> <paramname="LocalRenaming"type="Microsoft.Ajax.Utilities.LocalRenaming, ajaxmin" value="CrunchAll" /> <paramname="OutputMode"type="Microsoft.Ajax.Utilities.OutputMode, ajaxmin" value="SingleLine" /> <paramname="RemoveUnneededCode"type="bool"value="true" /> <paramname="StripDebugStatements"type="bool"value="true" /> </minifier> <minifiername="closure"type="Combres.Minifiers.ClosureJSMinifier, Combres"> <paramname="ApiUrl"type="string" value="http://closure-compiler.appspot.com/compile" /> <paramname="CompilationLevel"type="string"value="ADVANCED_OPTIMIZATIONS" /> </minifier> </jsMinifiers>
  • 20. ///<summary> /// CSS minifier which delegates the minification process to the /// YUI Compressor library (http://yuicompressor.codeplex.com/). ///</summary> publicsealedclassYuiCssMinifier : IResourceMinifier, IParametersReceiver { ///<inheritdoccref="IParametersReceiver.Binder" /> publicIObjectBinder Binder { get; set; } ///<inheritdoccref="IParametersReceiver.Parameters" /> publicIList<XElement> Parameters { get; set; } publicstringCssCompressionType { get; set; } publicint? ColumnWidth { get; set; } ///<inheritdoccref="IResourceMinifier.Minify" /> publicstring Minify(Settingssettings, ResourceSetrs, stringcombinedContent) { Binder.Bind(Parameters, this); var type = (CssCompressionType)CssCompressionType.ConvertToType( typeof(CssCompressionType), Yahoo.Yui.Compressor.CssCompressionType.StockYuiCompressor); returnCssCompressor.Compress(combinedContent, ColumnWidth == null ? -1 : ColumnWidth.Value, type); } }
  • 22. Future Direction Pluggable cache provider Velocity, DB Filter to support CSS expression Pipeline optimization Allow disable compression Idea? Bug? Feature? Contribution? http://combres.codeplex.com/Thread/List.aspx http://combres.codeplex.com/WorkItem/List.aspx http://combres.codeplex.com/SourceControl/UploadPatch.aspx
  • 23. Download Combres 1.2 http://combres.codeplex.com Download include Binary (.NET 3.5) and referenced libraries Source code & CHM doc Sample code Sample data files (with annotation) Licensed under Apache 2.0
  • 25. Step 1. Add References Red: required DLLs Blue: optional DLLs
  • 26. Step 2. Modify web.config
  • 27. Step 3. Create Combres Data File
  • 28. Step 4. Register Route in global.ascx
  • 29. Step 5. Link to Resource Sets