Bundles, Minification Andres Käver, IT Kolledž 2015 1.

Slides:



Advertisements
Similar presentations
MWD1001 Website Production Using JavaScript with Forms.
Advertisements

Introducing JavaScript
CHAPTER 15 WEBPAGE OPTIMIZATION. LEARNING OBJECTIVES How to test your web-page performance How browser and server interactions impact performance What.
ASP.NET Best Practices Dawit Wubshet Park University.
Razor. Slide 2 Remember this? Browser Web Server HTTP Request HTTP Response (Web page / code) Client code (script) Interpret request Generate HTML and.
Microsoft ® Official Course Developing Optimized Internet Sites Microsoft SharePoint 2013 SharePoint Practice.
Direct Congress Dan Skorupski Dan Vingo. Inner workings Reminder: MVC design pattern Procedural view: From request to response o Request passed to a view.
What’s new in ASP.NET MVC 3 Building a NerdDinner/AppStore Application.
UNIT-V The MVC architecture and Struts Framework.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Google Confidential & Proprietary Best Practices for Reducing HTML5 File Size Q
ASP.NET 5 Visual Studio 2015 Templates Bill Wolff Rob Keiser June 10, 2015.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, -
Building Highly Scalable Websites Karol Jarkovsky Sr. Solution Architect
ASP.NET and Model View Control Jesper Tørresø ITNET2 F08.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Web Performance Optimization Boban Stojanovski (Senior Front End Developer at Solaborate) Think Fast by default.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Lap Around Visual Studio 2008 &.NET 3.5 Enhancements.
Lecture 9: AJAX, Javascript review..  AJAX  Synchronous vs. asynchronous browsing.  Refreshing only “part of a page” from a URL.  Frameworks: Prototype,
Building Secure Web Applications With ASP.Net MVC.
Department of Computer Science Internet Performance Measurements using Firefox Extensions Scot L. DeDeo Professor Craig Wills.
JavaScript Syntax, how to use it in a HTML document
Crazy New CSS Tools MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
AxKit A member of the Apache XML project Ryan Maslyn Kyle Bechtel.
PERFORMANCE ENHANCEMENT IN ASP.NET By Hassan Tariq Session #1.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
Putting Performance Best Practices Together to Create the Perfect SPA Chris Love2Dev.com.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
Restricted © Siemens AG All rights reserved A Developer’s Insights Into Performance Optimizations for Mobile Web Apps CT DC AA EM LP2 | June 2015.
Unit 13 –JQuery Basics Instructor: Brent Presley.
Chap 2 – Getting Started COMP YL Professor Mattos.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
1 Minification JavaScript & CSS. 2 Minification Removing 0 Whitespace 0 Line Breaks 0 Comments 0 Shrink Variables 0 Optimize Code.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Craig Pelkie Copyright © 2015, Craig Pelkie ALL RIGHTS RESERVED Use RPG to Mobilize your IBM i.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Nivo 300 ASP.NET MVC 4 Danijel Malik Artifis Danijel Malik s.p.
The New Face of ASP.NET ASP.NET MVC, Razor, and jQuery Ido Flatow | Senior Architect | Sela | This session is.
MICROSOFT AJAX CDN (CONTENT DELIVERY NETWORK) Make Your ASP.NET site faster to retrieve.
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
I18n - DateTime ASP.NET MVC. I18n DateTime – EF changes  In model classes, use attributes  DataType(DataType.DateTime)  DataType(DataType.Date)  DataType(DataType.Time)
Enhance Your Page Load Speed And Improve Traffic.
I2CE Framework I2CE: Intrahealth Informatics Core Engine Base Web Framework on which iHRIS Manage and iHRIS Qualify are built on: Module Structure Magic.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Kendo UI ASP.NET MVC Wrappers
The Share Widget Library
Unit 4 Representing Web Data: XML
Kendo UI ASP.NET MVC Wrappers
ASP.NET MVC Advanced Topics
Building Web Applications with Microsoft ASP
Michael Robertson Yuta Takayama Google Closure Tools.
Web Caching? Web Caching:.
Microsoft Ajax Taking Ajax to the Next Level
SharePoint-Hosted Apps and JavaScript
Introduction to JavaScript
A second look at JavaScript
Intro to PHP.
Introduction to JavaScript
ASP.NET MVC Web Development
CIS 136 Building Mobile Apps
#01# ASP.NET Core Overview Design by: TEDU Trainer: Bach Ngoc Toan
Yale Digital Conference 2019
Presentation transcript:

Bundles, Minification Andres Käver, IT Kolledž

Bundling  Reduce the number of web requests  Glue (stitch) multiple files together  JavaScript, CSS, Images  Ordering is important! 2

Minification  Reduce the size of the file  Can be performed against any interpreted language (JavaScript, CSS,…)  Remove unused characters  Similar to compression  Browser can interpret the minified file as is 3

Minification - JS  Order does not matter  Can be processed alongside already bundled code Removal of line breaks Removal of final semicolon Removal of white space Shortening of local variable names 4

Minifaction - levels  Level 1 – removal of white space and comments  Level 2 – removal of extra semicolons and curly braces  Level 3 – local variable shortening  Level 4 – remove unreachable code  Level 5 – Global shortcuts and shortening of function names  Most minifiers work on Level 3 5

Minification  Jquery 300kb -> 100kb  Jquery UI 430kb -> 220kb  AngularJS 500kb -> 100kb !!!!! Higher level of minification??? 6

Why  Increase the performance  Mobile users have slow and costly connections  Reduce server load  Do not rely on the browser for caching  Development efficiences  Browsers have limits on simultaneous requests (typically 6 per hostname) 7

Tools  Inspect element – network  Yslow analyzer 8

ASP.NET Optimization library  Part of ASP.NET Web framework  Mature and complete  High level features Integrated with MVC Optimizations are auto-disabled in development Caching and versioning File ignoring, ordering, and extension replacements 9

Basic optimization  Global_asax  App_Start\BundleConfig.cs 10 protected void Application_Start(){ … BundleConfig.RegisterBundles(BundleTable.Bundles); } public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.validate*")); bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( "~/Scripts/modernizr-*")); bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( "~/Scripts/bootstrap.js", "~/Scripts/respond.js")); bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.css", "~/Content/site.css")); }

Basic optimization  Reference in views: _Layout.cshtml - My required: false)

Bundle declarations  Programmatic declaration  Series of transformations are applied  ScriptBundle and StyleBundle are convenience types (JsMinify, CssMinify)  Watch out for route naming conflicts (MVC, WEB-API, existing directories) Use prefix 12

Bundle MVC consumption  Debug mode will not use bundles  Scripts.RenderFormat – custom tags  Scripts.Url – just url path 13

Enabling optimizations  Optimizations are enabled automatically when not in debug  No minifying  Bundle paths are still available with transformations  Optimizations can be enabled programmatically - global 14 BundleTable.EnableOptimizations = true;

Lifecycle  Bundle module checks the request URL  Request is intercepted if Valid Bundle Path  Request is passed to a Bundle Http Handler  Returns 304 if cached  Check ASP.NET cache for previously built bundle  Begin rebuilding bundle  Razor view request – pre-process bundles found in views 15

Bundle building  Get files  Filter ignore list  Order files (jquery first)  Process file extension replacements  Build bundle 16

Caching & Versioning  Caching and versioning have been built in  /Content/css?v=RaidzmoMYrx5U9SiK8maUmu7qvhkDERc00iig4ul KpM1 /Content/css?v=RaidzmoMYrx5U9SiK8maUmu7qvhkDERc00iig4ul KpM1  1-year expiry  Ensure usage of Scripts & Styles helper  Cached bundles ARE NOT refreshed until server cache is refreshed 17

Ignoring files  *.intellisense.js  *.debug.js  Ignoring is built in  Can specify to ignore always, when optimization is enabled or when optimization is disabled  Default ignore patterns ignorelist,Ignore(“*.map”,….); 18

File extension replacements  Allows for tranformation of file names  Enables usage of the.min files in Optimization mode  Also adds.debug files when not in optimization mode  Custom file extension replacements can be included  BundleTable.Bundles. FileExtensionReplacemenList 19

Wildcard replacements  * - generic Only ONE wildcard can be used in a path  {version} is a special moniker Used for replacing version numbers in file names Not same as using * wildcard 20

File ordering  Important to include some Scripts and Styles before others  Jquery is often hard requirement  Reset CSS files 21

Content delivery networks  Multiple servers  Used for well known libraries (Jquery)  Takes load off your server  Caching  Built in support 22 bundles.Add(new ScriptBundle("~/bundles/jquery", " Include("~/Scripts/jquery-{version}.js"));