Interface ChunkAware

  • All Known Implementing Classes:
    CssCustomFunctionNode, CssCustomFunctionNode.CssCustomFunctionNodeProxy, CssDefinitionNode, CssFontFaceNode, CssFunctionNode, CssKeyframesNode, CssKeyNode, CssMediaRuleNode, CssProvideNode, CssRequireNode, CssSelectorNode

    public interface ChunkAware
    Interface to annotate CSS nodes with target CSS chunk id.

    Compiled CSS can be split into multiple parts to serve them separately, improving page load and browser's CSS parsing time. These parts are called chunks. Usually source code of a CSS chunk is a small group of CSS/GSS files.

    Because of inter-chunk dependencies (constant definitions and their references, and rules order) chunks are parsed and processed as a single file. On top of that, CSS size optimizations mix CSS rules coming from many chunks. The ChunkAware interface is used to preserve the chunk information during all those operations. Chunk information attached to a CSS node is used to print the optimized CSS AST into separate chunks. It can also be used to preserve CSS correctness while performing optimizations.

    The chunk id is represented as a general Object so that the user can choose a representation that it convenient for their task. In particular, tests simply use String as chunk ids. The type of the chunk ids cannot be parameterized because of the strange inheritance hierarchy of the CSS AST. Chunks are identified using Object.equals(java.lang.Object).

    • Method Detail

      • setChunk

        void setChunk​(java.lang.Object chunk)
        Sets the chunk id on the node.
        Parameters:
        chunk - an object identifying a chunk
      • getChunk

        java.lang.Object getChunk()
        Gets the chunk id of the node.
        Returns:
        the chunk id or null if no chunk id was previously set