Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Clean up: Refactor JS includes, use SVG Logo (with fallback) #73

Merged
merged 6 commits into from
Dec 17, 2014

Conversation

killercup
Copy link
Member

While writing the small PR earlier today to add the rustbyexample.com link (#72), I saw some pretty easy optimization opportunities.

This PR contains:

  • Moving some code to separate files in _includes to make it more readable
  • Use the SVG logo where possible (else fall back to the PNG one used previously)
  • Optimize the images includes using ImageOptim
  • Minify and embed the custom JavaScript files
  • Load the ACE editor files asynchronously

There is no new functionality added in this PR. I have tested the site using Chrome on OS X and IE9 on WIn7 (browser stack, only shortly, though). I would welcome it if some people on other OS' could confirm it still works.

@brson
Copy link
Contributor

brson commented Dec 12, 2014

Thanks. How do future maintainers update the minified js?

@killercup
Copy link
Member Author

Future maintainers need to minify the JS themselves, e.g. using UglifyJS (online). Should I add an explanation… and a Readme file?

Sadly, I haven't seen a way to automate this with Jekyll. If there is one, I'm of course open to suggestions (Github Pages doesn't allow Jekyll plugins, though).

@brson
Copy link
Contributor

brson commented Dec 12, 2014

@killercup Thanks for the explanation. Since this makes maintenance more complicated I'm inclined to not minify. The Rust home page doesn't strike me as performance critical.

@killercup
Copy link
Member Author

As a web frontend developer I try to squeeze every possible bit, but I might agree with you here. I'll have a look at how much bigger the index.html will be if I just include the non-minified sources.

How often is this page updated anyway? Minifying one file that is changed every four months or so might not be a big deal.

This also tries to fix some stuff in the custom JS code, e.g. wrapping
code in self-invoking functions to avoid setting global variables.
@brson
Copy link
Contributor

brson commented Dec 12, 2014

It's updated at least every six weeks for releases.

@killercup
Copy link
Member Author

A new release means a new download link, I presume. This shouldn't change any JS code, though. The platform detection code (to set the correct download link) could be easily refactored so that the package name is specified in the HTML code (or the YAML metadata).

The index.html currently embeds all custom JS files (detect platform, ace editor config and play.rust-lang.org, and an async loader).

index.html Size
Regular 17.5kB
Minified 11.3kB

The Rust home page doesn't strike me as performance critical.

It's the first thing a lot of people might see in regard to Rust, so I think it'd be nice to have it loaded as fast as possible.

Just let me know what you want to do, @brson. I have a patch ready to use the non-minified sources.

@brson
Copy link
Contributor

brson commented Dec 16, 2014

@killercup Hey sorry for the delay. I do think I prefer the non-minified version because it is easier for me to deal with. Let me know if I'm being unreasonable though.

@killercup
Copy link
Member Author

@brson Your not unreasonable—it's a very small page. Just don't expect PageSpeed to be all too happy ;)

My latest commit changes the index file to include the non-minified sources (but not deleted the minified files). It's trivial to change again if you change your mind.

brson added a commit that referenced this pull request Dec 17, 2014
Clean up: Refactor JS includes, use SVG Logo (with fallback)
@brson brson merged commit 4d237bd into rust-lang:gh-pages Dec 17, 2014
@brson
Copy link
Contributor

brson commented Dec 17, 2014

Thanks!

@killercup
Copy link
Member Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants