Giter Club home page Giter Club logo

frontend's Introduction

We're hiring!

Ever thought about joining us? https://workforus.theguardian.com/careers/product-engineering/

Frontend

The Guardian website frontend.

For everybody who engages with our journalism, theguardian.com is an industry-best news website that is fast, accessible and easy to use. Unlike other ways of developing products, ours puts the audience first.

Frontend is a set of Play Framework 2 Scala applications. It is built in two parts, using make for the client side asset build and SBT for the Play Framework backend.

For Articles, Frontend's responsiblity is to build JSON to pass to the modern rendering service, Dotcom Rendering.

Core Development Principles (lines in the sand)

These principles apply to all requests on www.theguardian.com and api.nextgen.guardianapps.co.uk (our Ajax URL)

  • Every request can be cached and has an appropriate Cache-Control header set.
  • Each request may only perform one I/O operation on the backend. (you cannot make two calls to the content API or any other 3rd party)
  • The average response time of any endpoint is less than 500ms.
  • Requests that take longer than two seconds will be terminated.

Documentation

All documentation notes and useful items can be found in the docs folder.

New developers

Welcome! How to set up and run frontend.

To get set up, please follow the installation guide.

Fixes for common problems can be found here.

Please read the development tips document to learn about more about development process.

For our deployment process, see how to deploy.

frontend's People

Contributors

arelra avatar austinh7 avatar desbo avatar ghaberis avatar gklopper avatar gtrufitt avatar jamesgorrie avatar janua avatar jfsoul avatar joelochlann avatar johnduffell avatar justinpinner avatar kaelig avatar katebee avatar kelvin-chappell avatar mxdvl avatar natalialkb avatar nathanielbennett avatar nicl avatar oliverjash avatar phamann avatar rich-nguyen avatar robertberry-zz avatar sammorrisdesign avatar shtukas avatar siadcock avatar sndrs avatar stephanfowler avatar tbonnin avatar tudorraul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frontend's Issues

Reduce icon sizes by using svg compression

The exported svg's that the designers supply us from Adobe based products contains a lot of cruft meta data we do not need, and in turn this bloats the data/uri's and css we serve.

I intend to build this node.js svg cleaner into the spricon.js build process to clean all svg's before base64 encoding them.

https://github.com/svg/svgo

EventEmitter logging

Monkey patch EventEmitter to console.log() all the on/emit events happening on the page.

Would also be nice to be able to assign the mediator to window.mediator for debugging.

PhantomJS

The purpose of the phantom box is to collect waterfall charts so that we can track quality of service over time.

  • A phantom box cloudformation with phantomjs dependencies
  • A scheduled job to hit a list of URLs via phantomjs netsniff and write the HAR our to disk
  • Flume the HAR logs to S3 for post-event analysis
  • Write some reports to show quality of service (Eg, wait time per host over the last 24 hours, js/css/html file size ratio etc.)
  • There may be some advantage in running this from both (or alternately) US and EU zones
  • Look at VPN options for testing via UK, USA, and other important areas
  • Think about bandwidth throttling to simulate 3g connections

404 Checking

Make something that checks all the links on the page resolve to a HTTP 200 when visited.

The desktop link football fixtures section resolves to a HTTP 404.

Possible image bug: different sizes of different images confusion

This article has some issues with image weirdness - note that the primary photo is the cave/lens flare, but when viewed on gucode we see the initial image of a pirate ship replaced with the correct one.

This seems to be because article.scala.html looks for an image with a width of 220px, and of all of the images (insert your own valid API key...) returned by the API for this article, only one (the pirate ship one) is sized at 220px. The pirate ship image itself is just an in-body image.

Not sure if this particular article is an anomaly, but worth double checking? API doesn't make it easy to tell when images are 'the same'.

Potential performance improvements to test

Documenting planned and possible performance improvements.

Move the script and font loader code to the bottom of the page.

We execute JS in the head to apply fonts before painting the page. In Chrome the HTML pre-parser doesn't download images. Canary does, Safari (including mobile) does, Firefox does, IE9 does. If Chrome doesn't catch-up before we take desktop traffic we might want to look at this, so that Chrome downloaded images in parallel with CSS.

Load app JS with standard script element and async defer attributes.

Gets modern browsers downloading app JS in parallel with CSS, and takes JS download time out of the critical path. Problem here is that browsers will download the app JS even if they don't cut the mustard. Unless... we cut the mustard on the server-side.

Defer load of auxiliary images

Fronts have a lot of images that load upfront, which are not core content. Remove some from the HTML and defer their load until they are required or other appropriate time.

Split gallery CSS/JS out of main CSS/JS file

Test the impact on file sizes.

JS bootstrap routing

Based on a discussion here, I have been thinking about our general bootstrapping of modules.

Currently found in :common/app/assets/bootstraps/article.js

This seems to now be global rather than just article bootstraping (which I agree with), but am worried that its going to become a very large file, with lots of if/switch statements testing which type of page you are on.

We have a set of common modules that need to be init'd on every page, but as the application grows we will find we only want to load specific modules for specific page types. For example the TrailblockToggle on the netwrok front or Autoupdate on live-blogging.

One possible solution that I have used in the past is to add the controllers name as a data attribute on the body tag and route/fork the init functions based on that:

Something similar to this:
http://viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution

What are peoples thoughts on this?
@commuterjoy @ahume @mattandrews @ironsidevsquincy

Compilation of assets during development slooooow

Any change to an asset file (css, javascripts) requires a full compilation of all the assets, which isn't conducive to fast development, and makes debugging harder

Preferably compilation (minification, concatenation) would not occur at development. References to JS files will need to lose the hash, and less.js should handle our css

Turn fonts on by default

There's a desire to enable fonts by default (within the constraints of connection speed, and other things we want to respond to).

The prefs module is used to enable fonts on a per user basis. We need a mechanism to decide whether it's on or off by default. Currently it's disabled simply because localStorage returning null translates to off.

At the moment, the test checks for fonts enabled on the app server switches AND the user pref. Does this need to be an OR check. There will likely be other user prefs that need this treatment.

Will think further.

Normalise AMD conventions

Sometimes we use vendor/module.js (Eg, bean) and sometimes we alias with paths (Eg, reqwest). We should normalise this to always use just the name.

Likewise, Bean is referenced as a specific version number in the define() statements, whereas we should be using the require.path object to alias the module name with the version we are using.

Other vendor/*.js modules are not version stamped at the moment, so we should find out the version of each module and rename the file.

SPDY

  • Install the nginx SPDY module
  • See what consequences it has on load speed etc.

Core navigation end points should send HTTP 204 when empty

Today the Content API sent an empty list of 'most viewed' content for a short period of time, and we sent the following to the end user, which was cached for 15 minutes.

http://m.guardian.co.uk/most-popular?callback=showMostPopular

showMostPopular({"html":"<div class=\"\" id=\"popular-trails\" data-link-name=\"most popular\"> <h2 class=\"type-2 article-zone\">Most read</h2> <div id=\"tabs-popular-1\" class=\" headline-list\" data-link-name=\"The Guardian\"> <ul class=\"unstyled\"> </ul> </div> </div>","refreshStatus":true});

We should probably send an HTTP 204 instead.

Improve Akamai caching

Sometimes it's caching 50% of requests, sometimes less. If we are going to use Akamai we should understand why it works in this way. IMHO we need a hard cache for the specified time in Cache-Control.

Logo dimensions change when switching between png/svg

The logo jumps by 1-2px's when the svg replacement kicks in after a few hundred milliseconds. This is mostly likely to do with the way the browser is handling the svg scaling or the svg width is sub-pixeled.

Therefore, we need to eliminate any issues by ensuring both the .png and .svg files are the exact same dimensions as each other, and that ratio is the same as the dom container.

I have asked Ben to re-supply the assets for us.

Improve page title tags

We seem to just have "single" title tags -- eg, just the article headline (whereas on desktop we do "headline | Section | guardian.co.uk". This has SEO implications so I'd advise we follow the format on guardian.co.uk.

Same goes for sections/tags: We just have "Video".

Fix jshint errors

There's a jshint branch with a lot of errors in. We should divide them up between ourselves and fix them.

Remove <meta> tags

We don't use any of the config meta tags in the page, so the need removing

<meta name="page-id" ...>

Evaluate access_logs Vs. the r2 redirect list

We want to modernise the www/r2 redirect list with a list of mobile and tablet user agents.

MOBILE_PATTERNS.add(".*Android.*");
MOBILE_PATTERNS.add(".*Blackberry.*");
MOBILE_PATTERNS.add(".*BlackBerry.*");
MOBILE_PATTERNS.add(".*Blazer.*");
MOBILE_PATTERNS.add(".*Ericsson.*");
MOBILE_PATTERNS.add(".*htc.*");
MOBILE_PATTERNS.add(".*HTC.*");
MOBILE_PATTERNS.add(".*Huawei.*");
MOBILE_PATTERNS.add(".*HUAWEI.*");
MOBILE_PATTERNS.add(".*iPhone.*");
MOBILE_PATTERNS.add(".*iPod.*");
MOBILE_PATTERNS.add(".*MobilePhone.*");
MOBILE_PATTERNS.add(".*mot.*");
MOBILE_PATTERNS.add(".*MOT.*");
MOBILE_PATTERNS.add(".*Motorola.*");
MOBILE_PATTERNS.add(".*MSN Mobile Proxy.*");
MOBILE_PATTERNS.add(".*NEC.*");
MOBILE_PATTERNS.add(".*nokia.*");
MOBILE_PATTERNS.add(".*Nokia.*");
MOBILE_PATTERNS.add(".*NOKIA.*");
MOBILE_PATTERNS.add(".*Novarra.*");
MOBILE_PATTERNS.add(".*O2.*");
MOBILE_PATTERNS.add(".*Opera Mobi.*");
MOBILE_PATTERNS.add(".*Palm.*");
MOBILE_PATTERNS.add(".*Samsung.*");
MOBILE_PATTERNS.add(".*SAMSUNG.*");
MOBILE_PATTERNS.add(".*Sanyo.*");
MOBILE_PATTERNS.add(".*SANYO.*");
MOBILE_PATTERNS.add(".*Smartphone.*");
MOBILE_PATTERNS.add(".*SonyEricsson.*");
MOBILE_PATTERNS.add(".*Symbian.*");
MOBILE_PATTERNS.add(".*Toshiba.*");
MOBILE_PATTERNS.add(".*Treo.*");
MOBILE_PATTERNS.add(".*vodafone.*");
MOBILE_PATTERNS.add(".*Vodafone.*");
MOBILE_PATTERNS.add(".*Windows CE.*");
MOBILE_PATTERNS.add(".*Xda.*");

First item of section list looks strange

The First item in the section list looks slightly weird now we have no padding within the list. We either need to add padding to top of list, or make the arrow blue when first item is selected.

Frontend diagnostics

The purpose of the diagnostics box is to collect client-side errors and events and feed them in to our reporting systems.

  • A diagnostics box cloudformation to log javascript errors & events - DONE
  • Catch window.onerror event and report to the box - DONE
  • Flume the logs to S3 for analysis - DONE
  • Expose metrics to Ganglia [1]
  • Refactor AMD modules to report errors & undesirable events [2]
  • Write some reports to show common errors, browser/os combinations etc. and make this information easily accessible

[1] Speak to Nick about gmond, ganglia and access_logs. Also need to figure out what we key the error on.
[2] The font loading module does this already for reporting slow localStorage rendering speeds

Javascript conventions

Below are some minor observations gathered during refactoring our JS bootstraping and modules. Some of which are consistent and others which need to be decided upon and then normalised across the modules and we can create a document or github page by which we can reference for future development.

Discussion on these conventions is encouraged ;) and please feel free to add more to the list!

Module initialising:

  • If module requires multiple parameter/arguments to initialise, a single object with named keys is prefered i.e:
new AutoUpdate({
     path: window.location.pathname,
     delay: 10000,
     attachTo: qwery(".matches-container")[0],
     switches: switches
}).init();

over

new AutoUpdate(indow.location.pathname, 10000, qwery(".matches-container")[0], switches);
  • All methods of a modules should be private unless methods that are required externally such as init().
    *Some of are modules return classes some of them don't. A modules should only be called using the 'new' constructor if there needs to be multiple instances on the page such tabs.

Naming conventions:

  • All file and method names should be camelCased with no hyphens or underscores.
  • Shorter abbreviated names are prefered for common actions, such as:
    init over initialise
  • Show and Hide action names are preferred if manipulating the DOM such as:
    showFrontFixtures();
  • Load is preferred over transclude if module is handling ajax requests.

Events:

This is a controversial one:

  • EventEmitter pub/sub is expensive, and makes modules harder to read. Therefore, a module should only emit and event if it is required for cross app/module communication or testing, and not for internal communication.
  • EventEmitter itself even warns if we go over a certain amount of events globally.

Logging:

  • All defensive error situation should be logged using the error module:
common.mediator('module:error', 'Failed to load more matches', 'more-matches.js');

Alt text is missing on images where certain image sizes are not available

@gklopper @phamann
The trail on the network front for the article: http://m.guardian.co.uk/world/2013/feb/13/christopher-dorner-charred-remains-cabin is missing Alt Text. This appears to be due to missing certain image asset sizes which are looked for to populate the alt text. However, alt text should always be populated as it is mandatory to populate it in R2/ESD tools. In the worst case we should populate an empty alt text, rather than none.

Trail image HTML is:
<img itemprop="contentURL" data-thumb-width="140" src="http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2013/2/13/1360748001458/Christopher-Dorner-005.jpg" class="maxed">

This was reported by my screenreader using friend Damon.

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.