Yellow Lab Tools

Untangling and counting the spaghettis...
Tested url:   {{phantomasResults.url}}
New test

Error: {{phantomasResults.error}}

Phantomas timed out
Phantomas config error
Phantomas failed to load page
Phantomas internal error
Javascript execution tree error
JSON undefined error

Grades

{{notations.domComplexity}}
DOM complexity
DOM elements count
{{phantomasResults.metrics.DOMelementsCount}}

A high number of DOM elements means a lot of work for the browser to render the page.

It also slows down Javascript DOM queries, as there are more elements to search through.

DOM max depth
{{phantomasResults.metrics.DOMelementMaxDepth}}

A deep DOM makes the CSS matching with DOM elements difficult.

It also slows down Javascript modifications to the DOM because changing the dimensions of an element makes the browser re-calculate the dimensions of it's parents. Same thing for Javascript events, that bubble up to the document root.

Number of iframes
{{phantomasResults.metrics.iframesCount}}

iFrames are the most complex HTML elements. They are pages, just like the main page, and the browser needs to create a new page context, which has a cost.

IDs duplicated
{{phantomasResults.metrics.DOMidDuplicated}}

IDs of HTML elements must be document-wide unique. This can cause problems with getElementById returning the wrong element.

{{notations.jsDomManipulations}}
DOM manipulations
DOM inserts
{{phantomasResults.metrics.DOMinserts}}

Working with the DOM in Javascript triggers layout calculations and slows down the page.

Try, as much as possible, to have an HTML page fully generated by the server instead of making changes with JS.

DOM queries
{{phantomasResults.metrics.DOMqueries}}

DOM queries are like looking in a large catalog of items. Even if the browsers made progress on the performances of queries, websites often make hundreds of them.

Try to reduce the number of queries by refactoring your Javascript code.

Avoid also to have a read query between two write queries. To be able to reduce the number repaints and optimize performances, browsers buffer the DOM writing operations and treat them in bulk. But each time a DOM reading is asked, the browser needs to empty the buffer. This can be particularly slow inside a loop.

Avoidable queries
{{phantomasResults.metrics.DOMqueriesAvoidable}}

This is the number of queries that could be avoided by removing all duplicated queries.

Simply save the result of a query in a variable. Ok it is not always simple, especially with third-party scripts, but at least do it with your own code.

Events bound
{{phantomasResults.metrics.eventsBound}}

Binding too many events has a cost.

It can be avoided by using "event delegation". Instead of binding events on each element one by one, events delegation binds them on the top level document element and uses the bubbling principle. It will imperceptibly slow down the event when it occurs, but the loading of the page will speed-up.

{{notations.jsBadPractices}}
Bad Javascript
Javascript errors
{{phantomasResults.metrics.jsErrors}}

Just to let you know there are some errors on the page.

Please note that some errors only occur in the PhantomJS browser, so you might need to double check on other browsers.

eval calls
{{phantomasResults.metrics.evalCalls}}

The 'eval' function is slow and a bad coding practice. Try to get rid of it.

document.write calls
{{phantomasResults.metrics.documentWriteCalls}}

They slow down the page construction, especially if they are used to insert scripts in the page. Remove them ASAP.

If you cannot remove them because they come from a third-party script (such as ads), have a look at PostScribe.

Console messages
{{phantomasResults.metrics.consoleMessages}}

Try to keep your console clean when in production. Debugging is good for development only.

Writing in the console has a cost, especially when dumping large object variables.

There is also a problem with Internet Explorer 8, not knowing the console object.

Global variables
{{phantomasResults.metrics.globalVariables}}

It is a bad practice because they clutter up the global namespace. If two scripts use the same variable name in the global scope, it can cause conflicts and it is generally hard to debug.

Global variables also take a (very) little bit longer to be accessed than variables in the local scope of a function.

DOM manipulations in body
{{inBodyDomManipulations}}

This metric counts the number of DOM queries, DOM inserts, binds, etc. made by the Javascript before the DOMContentLoaded event.

Wait for this event before manipulating the DOM. Do not execute Javascript in the middle of the BODY as it slows down the construction of the DOM and makes a poor maintainability. This is what i call spaghetti code.

The JS Timeline tab can help you identify what's happening.

{{notations.jQueryLoading}}
jQuery version
jQuery version
{{phantomasResults.metrics.jQueryVersion}}

Current latest versions of jQuery are 1.11 (with support for old IE versions) and 2.1 (without).

Each new version of jQuery optimizes performances. Do not keep an old version of jQuery. Updating can sometimes break a few things, but it is generally quite easy to fix them up. So don't hesitate.

{{phantomasResults.metrics.jQueryDifferentVersions}} versions loaded
{{version}} &

jQuery is a heavy library. You should **never** load jQuery more than one on the same page.

{{notations.cssComplexity}}
CSS complexity
Rules count
{{phantomasResults.metrics.cssRules}}

Having a huge number of CSS rules hurts performances. If the number of CSS rules is higher than the number of DOM elements, there is clearly a problem.

Huge stylesheets generally occur when the different pages of a website load all the CSS, concatenated in a single stylesheet, even if a large part of the rules are page-specific. Solution is to create one main CSS file with global rules and one custom files per page.

Complex selectors
{{phantomasResults.metrics.cssComplexSelectors}}

Complex selectors are CSS selectors with 4 or more expressions, like "#header ul li .foo".

They are adding more work for the browser, and this could be avoided by simplifying selectors.

Complex attributes selector
{{phantomasResults.metrics.cssComplexSelectorsByAttribute}}

Complex attributes selectors are one of these:

  • .foo[type*=bar] (contains bar)
  • .foo[type^=bar] (starts with bar)
  • .foo[type|=bar] (starts with bar or bar-)
  • .foo[type$=bar] (ends with bar)
  • .foo[type~=bar baz] (bar or baz)

Their matching process needs more CPU and it has a cost on performances.

{{notations.badCss}}
Bad CSS
CSS syntax error
{{phantomasResults.metrics.cssParsingErrors}}

Yellow Lab Tools failed to parse a CSS file. I doubt the problem comes from the css parser.

Maybe a CSS validator can help you.

Uses of @import
{{phantomasResults.metrics.cssImports}}

It’s bad for performance to use @import because CSS files don't get downloaded in parallel.

You should use <link rel='stylesheet' href='a.css'> instead.

Duplicated selectors
{{phantomasResults.metrics.cssDuplicatedSelectors}}

This is when two or more selectors are strictly identical and should be merged.

Duplicated properties
{{phantomasResults.metrics.cssDuplicatedProperties}}

This is the number of property definitions duplicated within a selector.

Empty rules
{{phantomasResults.metrics.cssEmptyRules}}

Very easy to fix.

CSS expressions
{{phantomasResults.metrics.cssExpressions}}

Such as: expression( document.body.clientWidth > 600 ? "600px" : "auto" )

This is a bad practice as it slows down browsers. There are some simpler CSS3 methods for doing this.

Uses of !important
{{phantomasResults.metrics.cssImportants}}

It can be useful, but only as a last resort. It is a bad practice because it overrides the normal cascading logic. The more you use !important, the more you need it again to over-override. This conducts to a poor maintainability.

Old IE fixes
{{phantomasResults.metrics.cssOldIEFixes}}

What browser do you need to support? Once you've got the answer, take a look at these old rules that pollute your CSS code and remove them.

IE6:

  • * html
  • html > body (everything but IE6)

IE7:

  • *height: 123px;
  • height: 123px !ie;

IE9:

  • -ms-filter
  • progid:DXImageTransform.Microsoft

Old prefixes
{{phantomasResults.metrics.cssOldPropertyPrefixes}}

Many property prefixes such as -moz- or -webkit- are not needed anymore, or by very few people. You can remove them or replace them with the non-prefixed version. This will help reducing your stylesheets weight.

Universal selectors
{{phantomasResults.metrics.cssUniversalSelectors}}

Universal selectors are the most expensive CSS selectors.

More informations here.

Redundant body selectors
{{phantomasResults.metrics.cssRedundantBodySelectors}}

This is one way to remove complexity from a CSS rule. Generally, when "body" is specified in a rule it can be removed, because an element is necessarily inside the body.

Redundant tags selectors
{{phantomasResults.metrics.cssRedundantChildNodesSelectors}}

Some tags included inside other tags are obvious. For example, when "ul li" is specified in a rule, "ul" can be removed because the "li" element is always inside a "ul". Same thing for "tr td", "select option", ...

Lowering compexity in CSS selectors can make the page load a little faster.

{{notations.requests}}
Requests number
Total requests
{{phantomasResults.metrics.requests}}

This is one of the most important performance rule. Every request is slowing down the page loading.

There are several technics to reduce their number:

  • Concatenate JS files
  • Concatenate CSS files
  • Embed or inline small JS or CSS files in the HTML
  • Create sprites or icon fonts
  • Base64 encode small images in HTML or stylesheets
  • Use lazyloading for images

Documents
{{phantomasResults.metrics.htmlCount}}
Scripts
{{phantomasResults.metrics.jsCount}}
Stylesheets
{{phantomasResults.metrics.cssCount}}
Images
{{phantomasResults.metrics.imageCount}}
Fonts
{{phantomasResults.metrics.webfontCount}}
Videos
{{phantomasResults.metrics.videoCount}}
JSON
{{phantomasResults.metrics.jsonCount}}
Other
{{phantomasResults.metrics.otherCount}}
{{notations.network}}
Network
404 not found
{{phantomasResults.metrics.notFound}}

404 errors are never cached, so each time a page ask for it, it hits se server. Even if it is behind a CDN or a reverse-proxy cache.

Connections closed
{{phantomasResults.metrics.closedConnections}}

This counts the number of requests not keeping the connection alive (specifying "Connection: close" in the response headers). It is only counting a request if it is followed by another request on the same domain.

This is slowing down the next request, because the brower needs to open a new connection to the server, which means a additional round-trip.

Correct the problem by setting a Keep-Alive header on the guilty server.

Duplicated requests
{{phantomasResults.metrics.multipleRequests}}

This only happens when the asset has no cache and is requested more than once on the same page. Be very careful about it.

Caching disabled
{{phantomasResults.metrics.cachingDisabled}}

Counts responses with caching disabled (max-age=0)

Fix immediatly if on static assets.

Caching not specified
{{phantomasResults.metrics.cachingNotSpecified}}

Responses with no caching header sent (either Cache-Control or Expires).

Every request should have a cache time specified. If you really don't want cache, specify "max-age=0", otherwise some browsers will try to cache.

Caching too short
{{phantomasResults.metrics.cachingTooShort}}

Responses with too short caching time (less than a week).

The longer you cache, the better. Add versionning to your static assets, if it's not already done, and set their cache time to one year.

Different domains
{{phantomasResults.metrics.domains}}

For each domain met, the browser needs to make a DNS look-up, which is slow. Avoid having to many different domains and the page should render faster.

By the way, domain sharding is not a good practice anymore.

Javascript Timeline

This graph gives a quick view of when the Javascript interactions with the DOM occur during the loading of the page.

Timestamp: {{$index * timelineIntervalDuration | number: 0}} ms
0 ms
{{endTime | number: 0}} ms
DOM creation
DOM interactive
DOM content loaded event
Page completion
Page is complete
Executing Javascript and DOM queries here is a bad practice and slows down the DOM construction.
Some frameworks do things here, but it's not reliable and should be avoided.
Also known as "document ready". This is where you should execute top-priority scripts, like binding action buttons or launch a video player.
Here you can execute mid-priority tasks. Loading a script with createElement('script') is one way to do so.
The page is considered loaded, it's time for low priority things : trackers, social plugins, easter egg...

Javascript Profiler

The table below shows the interactions between Javascript and the DOM. It is useful to understand what happens while the page loads.

Filter by
Type
Params
Timestamp
{{$index + 1}}
{{node.data.type}}
{{node.data.callDetails.arguments[0]}} : {{node.data.callDetails.arguments[1]}} : {{node.data.callDetails.arguments[2]}} : {{node.data.callDetails.arguments[3]}}

Called on DOM element

{{node.data.callDetails.context.domElement}}

Called on 0 jQuery element

Useless function call, as the jQuery object is empty.

Called on 1 jQuery element

{{node.data.callDetails.context.firstElementPath}}

Called on {{node.data.callDetails.context.length}} jQuery elements

The .bind() method attaches the event listener to each jQuery element one by one. Using the .on() method is preferable if available (from v1.7).

First one is: {{node.data.callDetails.context.firstElementPath}}

The query returned 0 results. Could it be unused or dead code?

Backtrace

{{trace.fnName || '(anonymous)'}}
can't find any backtrace :/

Sub processes

Type
Params
Duration
{{$index}}
{{node.data.type}}
{{node.data.callDetails.arguments[0]}} : {{node.data.callDetails.arguments[1]}} : {{node.data.callDetails.arguments[2]}} : {{node.data.callDetails.arguments[3]}}
{{node.data.time}} ms
{{node.data.timestamp | number: 0}} ms