Friday, June 22, 2018

Improving Performance Perception with Pingdom and GTmetrix

This article is part of a series on building a sample application --- a multi-image gallery blog --- for performance benchmarking and optimizations. (View the repo here.)


In this article, we'll analyze our gallery application using the tools we explained in the previous guide, and we'll look at possible ways to further improve its performance.

As per the previous post, please set up Ngrok and pipe to the locally hosted app through it, or host the app on a demo server of your own. This static URL will enable us to test our app with external tools like GTmetrix and Pingdom Tools.

GTmetrix first test

We went and scanned our website with GTmetrix to see how we can improve it. We see that results, albeit not catastrophically bad, still have room for improvement.

The first tab --- PageSpeed --- contains a list of recommendations by Google. The first item under the PageSpeed tab --- a warning about a consistent URL --- pertains to our application outputting the images randomly, so that is an item we will skip. The next thing we can do something about is browser caching.

Browser Caching

Browser caching

We see that there is a main.css file that needs its Expires headers set, and the images in the gallery need the same thing. Now, the first idea for these static files would be to set this in our Nginx configuration:

location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    expires 14d;
}

We can simply put this inside our server block and leave it to Nginx, right?

Well, not really. This will take care of our static files, like CSS, but the /raw images we are being warned about aren't really that static. So this snippet in our Nginx configuration won't exactly fix this issue so easily. For our images, we have an actual controller that creates these on the fly, so it would be ideal if we could set our response headers right there, in the controller. For some reason, these weren't being set properly by Glide.

Maybe we could set our Nginx directive in a way to include the raw resources, but we felt the controller approach to be more future-proof. This is because we aren't sure what other content may end up with an raw suffix eventually --- maybe some videos, or even audio files.

So, we opened /src/ImageController.php in our image gallery app, and dropped these two lines inside of our serveImageAction(), just before the line return $response:

// cache for 2 weeks
$response->setSharedMaxAge(1209600);
// (optional) set a custom Cache-Control directive
$response->headers->addCacheControlDirective('must-revalidate', true);

This will modify our dynamic image responses by adding the proper Cache Control and Expires headers.

Symfony has more comprehensive options for the caching of responses, as documented here.

Having restarted Nginx, we re-tested our app in GTmetrix, and lo and behold:

Browser Caching

The post Improving Performance Perception with Pingdom and GTmetrix appeared first on SitePoint.


by Tonino Jankov via SitePoint

How to use JavaScript modules on the web

#391 — June 22, 2018

Read on the Web

JavaScript Weekly

Using JavaScript Modules on the Web — Node supports ES modules, Firefox 60 supports ES modules, indeed most browsers do so you might enjoy this Chrome-themed explanation of what they are, how to use them in the browser, and how to keep them fast.

Addy Osmani and Mathias Bynens

A Minimal Guide to ECMAScript Decorators — Decorators, which would provide a handy syntax to mutate functions or classes, are currently at stage 2 of TC39’s process, but how are they likely to work?

Uday Hiwarale

See Why Facebook, Spotify, & fastlane Trust CircleCI with Their CI/CD — Automate the software development process using continuous integration and continuous delivery so you can focus on what matters: building great things, not waiting for great things to build.

CircleCI sponsor

Billboard.js 1.5 Released: Easy JS Charts — A chart library that uses D3 under the hood. This release adds a new ‘radar’ chart, improved text positioning and clipping, bug fixes, etc.

Jae Sung Park

▶  The Cost of JavaScript — In just 20 minutes Addy Osmani covers approaches to delivering JavaScript in an efficient way to ensure your users experiences are as seamless and smooth as possible.

Addy Osmani

Node 10.5 Released with Experimental Worker Threads Support — Interested in the multi-threading? Check the FAQ and this pull request with example usage.

Node.js Foundation

V8 Release V6.8 — 6.8 is now in beta and will be going mainstream with next month’s Chrome 68. Nothing huge feature-wise but some minor memory and performance improvements.

Mathias Bynens

Github Stars !== Usage: React Still More Popular than Vue — Last week there was a fun community story around Vue.js getting more stars on GitHub than React, but while Vue is growing fast, React still dominates in actual usage.

Kevin Ball

💻 Jobs

JavaScript Developer at X-Team (Remote) — We help our developers keep learning and growing every day. Unleash your potential. Work from anywhere. Join X-Team.

x-team

Senior Front End Developer (Charlotte, NC) — Bring your skills to create, code and optimize websites & user experiences for some of the biggest brands in the US. Join us at RV.

Red Ventures

Have You Tried Vettery? — Vettery matches top tech talent with fast-growing companies. Take a few minutes to join our platform.

Vettery

📘 Tutorials and Opinions

Building a RSS Viewer with Vue.js

Raymond Camden

The Trouble with D3? — D3 is phenomenally powerful, but requires you have a grasp of many concepts to use it well.

Ian Johnson

Writing Your Own ESLint Plugin — Handy for if you or your company have specific code conventions or preferences you want to enforce.

Watandeep Sekhon

Why Do JavaScript Test Frameworks Use describe() and beforeEach()? — Check out our detailed blog based on the State of JavaScript Survey. Helpful links for intermediate to advanced developers.

Big Nerd Ranch sponsor

Why 'Mapping' a Constructed Array Doesn't Work in JavaScript — And a way around the issue.

Shawn Reisner

The Internals of Shadow DOM and How to Build Self-Contained Components — A basic introduction to building Web Components.

Alexander Zlatkov

Build a Single Page App from Scratch Without a Framework — Using jQuery (yes!), Handlebars, Express and Axios.

Michael Wanyoike

Building A Serverless Slack Bot using Cloudflare Workers and JavaScriptWorkers is a serverless/edge-computing platform Cloudflare operates.

Rita Kozlov (Cloudflare)

Build a Custom App for Slack

Slack sponsor

How To Build Dynamic Components in Angular 6

Rajat S

Implementing an Infinite Scroll with Vue.js

Dave Berning

🔧 Code and Tools

Material Dashboard: A Bootstrap 4 Material Design Admin Dashboard — Comes in plain HTML, React, Vue, and Angular varieties. Demo.

Creative Tim

Introducing Akita: A New State Management Pattern for Angular Apps — Built on top of RxJS.

Netanel Basal

Realtime. Real Simple — Build and scale interactive, immersive apps with PubNub - chat, collaboration, geolocation, device control and gaming.

PubNub sponsor

number-flip: Increase a Count/Number with a Flipping Animation

日天

Phoenix: A macOS Window and App Manager Scriptable with JavaScript — Written in Objective C, but you can create scripts like this with JavaScript.

Kasper Hirvikoski

Sprite.js: A Cross-Platform Lightweight 2D Render Object Model

Akira Wu

Electron 3.0.0 Beta 1 Release — Significant due to the dependency upgrades (Chrome from 61 to 66, Node from 8 to 10, V8 from 6.1 to 6.6).

Electron


by via JavaScript Weekly

Sole

‘Sole’ is a Landing Page WordPress theme built on the Bootstrap Framework. There are pre-designed home pages covering 6 different industries, my favorite being the app Landing Page. Features include a subtle parallax as you scroll, a sticky header navigation that smooth scrolls to sections, attractive device feature layouts, testimonials, newsletter sign up divider and ends strong with FAQs and alongside contact form.


by Rob Hope @robhope via One Page Love

The History of File Sharing - #infographic

Here's an infographic illustrating the timeline of how humans have shared information throughout the ages.

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

boutique style

boutiquestyle is a corporate website. Mobile compatible coding is performed


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Crypton

Crypton is a cryptocurrency trading bot based on machine learning, which analyses trading transactions, predicts changes, selects growth points and signals to sell or buy crypto.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Villa Louisa

The Villa Louisa Dental Clinic is an exclusive private clinic where aligning teeth is done only with aligners Invisalign. As aesthetic dental specialists, we use advanced techniques to create a smile which will harmonize with your face.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery