##How to view this project
###Local
After building, find the dist
folder in the project and open index.html
###Online
View on github at http://m-coding.github.io/fe-04-optimization
##Build Tool Requirements
- Check it is properly installed:
node -v
npm -v
- Required for
gulp-imagemin
- Check it is properly installed:
gm -version
- Navigate to the project directory (where the
gulpfile.js
is located). - In your terminal enter the command:
npm install
- This will install all modules listed as dependencies in
package.json
- Windows Tip:
- You see the error
Please try running this command again as root/Adminstrator
- Start Git Bash as administrator (right-click and select Run as adminstrator)
##Build the Project
Make sure you satisfy the Build Tool Requirements first.
- Navigate to the root of the project directory in your terminal.
- Check that
node_modules
folder exists. If not, see step 3 under Build Tool Requirements. - Enter the command
gulp clean
to delete everything in thedist
folder.
- If you want to preview what files will be deleted, enter the command
gulp cleanDryRun
instead.
- Next enter the command
gulp
and the project will be built in thedist
folder.
- You can review differences by comparing the
src
anddist
folder.
##Optimizations
####index.html
- Resized thumbnail images to be 100px by 62px
- Resized large images to be a max width of 480px
- Compressed the images
- Removed optional analytics script
- Inlined styles from
style.css
into the<head>
- Minified inline styles
- Add
media="print"
attribute forprint.css
- Minified print styles
- Use Web Font Loader to load Google fonts
PageSpeed Insights: Scored Above 90
####pizza.html
- Resized large images to be a max width of 360px
- Add properties to the
.mover
class instyle.css
- Set width and height properties
- Add
backface-visibility: hidden;
property - Add
transform: translateZ(0);
andwill-change: transform;
properties
- Replace
querySelector
withgetElementById
inresizePizzas
- Refactor
changePizzaSizes()
inmain.js
to prevent Force Synchronous Layout
- Move
sizeSwitcher()
logic here and removedetermineDx()
- Use
getElementsByClassName
instead ofquerySelectorAll
- Move constant variables outside for loops
- Simplified loop logic
- Refactor
updatePositions()
inmain.js
to reduce Scripting Time
- Use
getElementsByClassName
instead ofquerySelectorAll
- Save
scrollTop
variable outside loop - Save phase sequence values in an array
- Use
transform
instead ofleft
to set x-axis position ofpizza.png
- Refactor
DOMContentLoaded
event listener function
- Declare variables outside of loop
- Removed
height
andwidth
properties, already defined in.mover
class - Removed
basicLeft
and setleft
property - Use
getElementById
instead ofquerySelector
- Minified
main.js