Git Product home page Git Product logo

news-aggregator's Introduction

News Aggregator


Description

This is a project from the Udacity Front-End Web Developer nanodegree. This project focused on optimizing an existing web site, and using debugging skills. There are many known bugs in the existing site that need to be fixed in order to make the site run faster and smoother. This repo represents my submission to the project.


How to Load the website

You can load the website in two ways:

  1. From this GitHub pages - open the website.

  2. Download the repo locally - You can either download a zip file from the repo or you can clone the repo onto your local machine. Once downloaded onto your local machine, you can do one of two things to view: -- Open the dist/index.html file that is in the root directory of the repo, with a browser (i.e. Chrome, Firefox). -- Host the files through a local web server, and use your browser to navigate to the local web server. For example, if you have python installed, you can run this command within the dist/ of the repo directory to serve the files:

    python -m SimpleHTTPServer 8080 # assuming port 8080 is not used already.
    

    Then you can navigate your browser to localhost:8080/


Optimizations

Page Rendering and Painting

  • The original app created a story details widget for each story when clicked. So, I changed that so that there was only one widget, which got updated with the active story when clicked. This reduced the number of DOM elements significantly, and excess layers.
  • Layers (via will-change) were being created for individual elements of the story details widget. I removed the CSS for any children of the story details, and only kept it for the main story details element. This reduced the number of layers.
  • Wrapped the loadStoryBatch function with a requestAnimationFrame, to make sure the visuals were being painted at the correct time.
  • re-factored the colorizeAndScaleStories function to optimize it, by separating the reading and writing into separate batches, reduced calculations, and reduced the number of stories being work on at one time (only visible items).
  • Removed the loop in onStoryData, since the element can be queried directly, without the looping.
  • Used CSS transform, instead of javascript for the story details animation.

Page Loading

  • Minified CSS with htmlmin to reduce file size
  • Minified JS with uglify-js to reduce file size
  • Inlined CSS to avoid another round trip with inline-source
  • Inlined javascript files namespace.js, app.js and data.js to avoid another round trip with inline-source

Page Speed Insights Results:

Page Speed Insight analysis

Chrome DevTools Audit (Lighthouse)

Received a performance score of 89 (good)

General Observations

From Chrome DevTools Performance tab, you can visually see a huge difference between the old and new for both page loading, scrolling and story detail animation. FPS generally average almost double improvement.

Optimization Summary
Page Speed Mobile Page Speed Desktop Chrome Perf Audit
Original Optimized Original Optimized Original Optimized
65 78 85 88 62 89

Build Automation

Used Gulp to automate the building and common tasks of the website. Includes the following:

  • minification of javascript using uglify
  • minification of HTML and CSS using htmlmin
  • inlining CSS using inline source
  • Javascript linting using jshint
  • CSS linting using csslint
  • moves all assets under the dist/ directory

Gulp dependencies are in the package.json file

You need to install nodejs/npm and gulp first.

To generate distribution, run the following in the root directory of the repo

Install Dependencies

npm install

Generate Distribution

gulp main

You can run individual tasks by replacing main with either html, csslint,js or img The resulting files for distribution will be in the dist/ directory


Resources


License

This project is licensed under the terms of the MIT license. (See LICENSE.md)

Copyright (c) 2018 Brett Schwarz

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.