Managing Your Bundle Size - Totally Tooling Tips

Chrome for Developers · Beginner ·🌐 Frontend Engineering ·8y ago

Key Takeaways

Manages bundle size using Bundlesize and Lighthouse tools

Full Transcript

[Music] hey books so today we're gonna talk about keeping an eye on your JavaScript bundle size very very important we've already been hit under there by a number of projects number projects is there a few different ways that you can do this if your projects on github and you care about things like continuous integration there's a nice little package called bundle size you can drop in it's also a CLI so you can use it locally as well also CLI and the idea behind bundle size is that you know once you've got to configure you can say well I've got these bundles I've got like a tender bundle I've got my main application logic ones and I don't want those bundles to exceed a certain size and so you know if people are filing PRS against your project it's very easy to see where the following off tell them you know hey this is crossing our budget for JavaScript bundle size please make your code smaller the nice thing is well I think it actually reports like what this like the PR size would be in terms of particular like this file is this size this father size even if you're not reaching your threshold maybe you could say Ashley this is a huge jump compared to I saw last PR so yeah yeah the other side you it doesn't have to be a bundle right that you could just say this javascript file what size is it yeah yeah just just checking yeah it's it's pretty nice and it works off of gzip sizes as well so you get a picture into your what the final final size might look like nice so that bundle size took me like only 10 minutes to setup on one of my apps fairly low friction mostly works off your package a JSON file folks check it out you did in looking at some of the stuff too yeah so with work box we kind of have a file size kind of concern and we've been trying to like figure out how we can actually stay on top of it because it we kind of did all this work we released this thing and now we're like cool what is the actual file size of this and it's not what we'd like it to be so we're working on a rewrite and part of that is let's get it into our CI so that way we can just whenever we do a PR what is the current size what is it now and it's super nice the idea I think we took from Mosin lyft where it's he's actually like written a little bot that would say this is the change for this PR has it gone down has it gone up and started like flagging thresholds around the percentage of increase or decrease so I've been making my own little buck thing so we can do the same thing and maybe some additional stuff as well with little plugins the idea is just to help we're tracking like what is master what is this pull request doing and then adding like those similar sort of thresholds great and one of the nice things about that is it's able to show you the before and after cost for every single file yeah like I I don't know like I think muslins one was the first one where I'd actually seen it was like ah that actually totally makes sense you should definitely have that and everyone should just have it in the deci I yeah I would love to see more people like more teams integrating this since their workflow I think it's I think it's really tight and another thing lyft have been doing is so we talked about lighthouse and CI in one of our last episodes um they're they're combining sort of bundle size impacts measurement with lighthouse measurements as well so keeping an eye on all their runs which is kind of kind of nice to see it's almost as if there's a tool that would take plugins and run out and get hub would just be super useful right now so another thing you can do if you're locally developing is we worked on this feature with web pack called performance budgets and the idea is that you were able to set the budgets that you want you and your teams follow for your different bundles so by default web pack uses a bundle size of about 250 kilobytes your team I have something a little bit more specific a little bit smaller a little larger but this feature is just great for you know every time you're working on a change you're trying to do a local bill just being able to make sure that you're not exceeding your team's budgets quite as much as you could be so this would do this at Build time and presumably it does it throw an error or does it still let you build and deploy but it's just like flagging it as an issue so you can it can do a warning it can also throw it as an error as my understanding so noise god you've got your your basis covered there yeah so that's web packs performance budget features something we saw this week that was kind of neat was another tool call it's a plugin for Visual Studio code yeah called the vs code import cost extension and one of the really nice things about this is that it can display in line in your editor as you're working on your code like the cost of imports as you're working on them so it shows you like a little bit of a comment at the very end of line that says you know like low - just 70 kilobytes or I was gonna say this is like highlighting the sure that we flaked up a couple of episodes ago around using particular plugins to help you get around sort of file size things and this is a really nice example where it actually flex it like right in your editor which is awesome yeah and this is running like the ability by pac plugin behind the scenes so it's four es module style packages it's going to at least be giving you an approximate for what the minified size is going to look like okay we've also been talking to them about maybe highlighting the gzip size but it's still it's still a good gut check for now yeah I don't know I think anything where it immediately makes you think okay I'm about to require this third-party module it's instant like well this is the hit you're you're incurring from that which is really nice really useful yeah so we talked about continuous integration we talked about what you can do locally another thing folks might benefit from is being able to measure like in production what the impact of their bundle sizes are over time to get services for this our speed curve and caliber so caliber these are kind of tools way you say this is my website and they'll keep on like pinging it on a regular basis run a load of tests on them and then kind of report on a ongoing basis right pretty much yeah so one of the nice things about caliber is that you're able to specify like your target devices you can say well yeah I'm targeting desktop and targeting these mobile devices and it'll be able to show you your bundle size like over time like your JavaScript that you're sending down to people so that's super handy if you like basically sending down different assets based on like media queries or user agents or what-have-you exactly nice so if a member of your team accidentally pushes out like a feature that's got a lot of JavaScript in there that's gonna you know decrease time to interactive you know have an impact on your page performance or if they push out a pull request that means that everything is like way faster because the bundle size is smaller let's be positive yeah yep that is well good way to see both both wins and places where you should probably cry but caliber is really great for checking that stuff out so hopefully folks have got their bases covered you know if they want to check this stuff out locally then I got it then go to CLI they got the pour requests and then they've got actual production regular testing yeah and it's worth saying like it's worth doing this stuff up front because a little bit of effort now should help you in the long term because it's just regularly tracking and you don't there's no babysitting it's just you know if these things so just definitely check these tools out yeah these tools are awesome for helping you you know just make sure you're stripping the minimal amount of JavaScript to your users you know defer the rest that work until later point in time but yeah try them out let us know what you think Thanks [Music]

Original Description

The amount of JavaScript you send to your users can affect your load and parse time of your Javascript resulting in a slow feeling site. In this episode, learn how to keep track of your bundle size during development and get accustomed with tools that will help you track your bundle size over time. Links from the episode: Bundlesize: https://github.com/siddharthkp/bundlesize Lighthouse: https://developers.google.com/web/tools/lighthouse/ Calibre: https://calibreapp.com/ pr-bot: https://github.com/GoogleChromeLabs/pr-bot vscode-import: https://marketplace.visualstudio.com/items?itemName=wix.vscode-import-cost speedcurve: https://speedcurve.com/ Watch more episodes of Totally Tooling Tips here: https://goo.gl/IoXka7? Subscribe to the Chrome Developers channel at http://goo.gl/LLLNvf
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Chrome for Developers · Chrome for Developers · 0 of 60

← Previous Next →
1 Polymer Performance Patterns (The Polymer Summit 2015)
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
2 Polymer Power Tools (The Polymer Summit 2015)
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
3 Chrome Dev Summit 2014 – Chrome Case Studies
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
4 Web Directions Code 2015 round up
Web Directions Code 2015 round up
Chrome for Developers
5 Maintainable Code - HTTP203
Maintainable Code - HTTP203
Chrome for Developers
6 iron-ajax… wat?! -- Polycasts #26
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
7 The Guardian - Supercharged
The Guardian - Supercharged
Chrome for Developers
8 ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
9 #AskPolymer: Rob answers all the questions ever -- Polycasts #27
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
10 The Future of JavaScript - HTTP203
The Future of JavaScript - HTTP203
Chrome for Developers
11 Data Binding 101 -- Polycasts #28
Data Binding 101 -- Polycasts #28
Chrome for Developers
12 The Guardian part 2 - Supercharged
The Guardian part 2 - Supercharged
Chrome for Developers
13 The Future of Web Audio: with Chris Wilson and Chris Lowis
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
14 Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
15 Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
16 #AskPolymer: How do you make the show? -- Polycasts #29
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
17 Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
18 Binding to Objects -- Polycasts #30
Binding to Objects -- Polycasts #30
Chrome for Developers
19 Player FM - Supercharged
Player FM - Supercharged
Chrome for Developers
20 Where’s the Designer? #AskPolymer -- Polycasts #31
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
21 Jake Beats Wikipedia - HTTP203
Jake Beats Wikipedia - HTTP203
Chrome for Developers
22 Supercharged Observers! -- Polycasts #32
Supercharged Observers! -- Polycasts #32
Chrome for Developers
23 Jai's Web blog - Supercharged
Jai's Web blog - Supercharged
Chrome for Developers
24 Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
25 What about internationalization? #AskPolymer -- Polycasts #33
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
26 Developing for Billions (Chrome Dev Summit 2015)
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
27 Google+ Performance Improvement Comparison
Google+ Performance Improvement Comparison
Chrome for Developers
28 Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
29 Progressive Web Apps (Chrome Dev Summit 2015)
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
30 Instant Loading with Service Workers (Chrome Dev Summit 2015)
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
31 Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
32 Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
33 Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
34 Polymer - State of the Union (Chrome Dev Summit 2015)
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
35 Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
36 Introduction to RAIL (Chrome Dev Summit 2015)
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
37 DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
38 RAIL in the real world (Chrome Dev Summit 2015)
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
39 #ChromeDevSummit talks are up - W00T! -- Polycast #34
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
40 V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
41 Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
42 Owning your performance: RAIL (Chrome Dev Summit 2015)
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
43 HTTP/2 101 (Chrome Dev Summit 2015)
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
44 Leadership Panel (Chrome Dev Summit 2015)
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
45 Build Processes, Totally Tooling Tips (S2, Ep 5)
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
46 Accessibility (Chrome Dev Summit 2015)
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
47 Binding to Arrays -- Polycasts #35
Binding to Arrays -- Polycasts #35
Chrome for Developers
48 HTTP2 - HTTP203
HTTP2 - HTTP203
Chrome for Developers
49 Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
50 Call For Submissions - Supercharged
Call For Submissions - Supercharged
Chrome for Developers
51 Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
52 Testing AJAX with Web Component Tester -- Polycasts #37
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
53 Slack: Extended Xmas Special - Supercharged
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
54 Browser testing with Travis & Sauce Labs -- Polycasts #38
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
55 Optimize for production with Vulcanize -- Polycasts #39
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
56 Highlights from Chrome Dev Summit 2015
Highlights from Chrome Dev Summit 2015
Chrome for Developers
57 Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
58 Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
59 How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
60 Colors – DevTools Tonight #0 (Pilot)
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers

Related Reads

📰
Inside the Wayfair Frontend SDE-2 Interview: A Complete Breakdown
Learn how to prepare for a Frontend SDE-2 interview at Wayfair, including online assessments, machine coding, and system design.
Medium · Programming
📰
I Spent Two Years Maintaining a React SPA. HTMX Rebuilt It in a Week
Learn how HTMX rebuilt a React SPA in a week, replacing 2 years of maintenance work, and discover the benefits of this alternative approach
Medium · Programming
📰
The 5 Levels of Front End Engineering (And Where Most Developers Get Stuck)
Learn the 5 levels of front end engineering to improve your skills and avoid getting stuck in a career rut
Medium · Programming
📰
Browser-Based PDF Editing with Vue 3 and pdf-lib
Learn to build a browser-based PDF editor using Vue 3 and pdf-lib, enabling users to edit PDFs directly in the browser
Dev.to · sunshey
Up next
How To Build A Twitter Clone - React Next JS - Appwrite Crash Course
Adrian Twarog
Watch →