Page Speed Optimization Libraries
1.7.30.1
|
#include "critical_css_beacon_filter.h"
Public Member Functions | |
CriticalCssBeaconFilter (RewriteDriver *driver) | |
virtual const char * | Name () const |
virtual const char * | id () const |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
Static Public Attributes | |
static const char | kInitializePageSpeedJs [] |
static const char | kCriticalCssBeaconAddedCount [] |
Statistics: | |
static const char | kCriticalCssNoBeaconDueToMissingData [] |
static const char | kCriticalCssSkippedDueToCharset [] |
Protected Member Functions | |
virtual bool | MustSummarize (HtmlElement *element) const |
virtual void | Summarize (Css::Stylesheet *stylesheet, GoogleString *out) const |
virtual void | SummariesDone () |
virtual void | DetermineEnabled () |
Figure out the set of CSS selectors referenced from a page, saving those selectors in an OutputResource for each CSS <style> or <link> on the page. Based on that set of candidate critical selectors, inject javascript for detecting critical above the fold css selectors after the page has loaded. Assumes CSS have been flattened first.
virtual void net_instaweb::CriticalCssBeaconFilter::DetermineEnabled | ( | ) | [protected, virtual] |
Override DetermineEnabled so that filters that use the DOM cohort of the property cache can enable writing of it in the RewriterDriver. Filters inheriting from RewriteDriver that use the DOM cohort should override UsePropertyCacheDomCohort to return true.
Reimplemented from net_instaweb::RewriteFilter.
virtual bool net_instaweb::CriticalCssBeaconFilter::MustSummarize | ( | HtmlElement * | element | ) | const [protected, virtual] |
This method should be overridden if some CSS should not go through the summarization process (eg because it uses an inapplicable media type and we'll just throw it away when we're done anyway). By default all CSS must be summarized.
Reimplemented from net_instaweb::CssSummarizerBase.
virtual void net_instaweb::CriticalCssBeaconFilter::SummariesDone | ( | ) | [protected, virtual] |
This is called at the end of the document when all outstanding summary computations have completed, regardless of whether successful or not. It will not be called at all if they are still ongoing, however.
It's called from a context which allows HTML parser state access. You can insert things at end of document by constructing an HtmlNode* using the factories in HtmlParse and calling CommonFilter::InsertNodeAtBodyEnd(node).
Note that the timing of this can vary widely --- it can occur during initial parse, during the render phase, or even at RenderDone, so implementors should not make assumptions about what other filters may have done to the DOM.
Base version does nothing.
Reimplemented from net_instaweb::CssSummarizerBase.
virtual void net_instaweb::CriticalCssBeaconFilter::Summarize | ( | Css::Stylesheet * | stylesheet, |
GoogleString * | out | ||
) | const [protected, virtual] |
This should be overridden to compute a per-resource summary. The method should not modify the object state, and only put the result into *out as it may not be invoked in case of a cache hit. The subclass may mutate *stylesheet if it so wishes.
Note: this is called on a rewrite thread, so it should not access HTML parser state.
Implements net_instaweb::CssSummarizerBase.