Documentation
Feedback
Guides
Learning Center

Learning Center
Learning Center
Improving initial load
View in Portuguese
This content was migrated from the VTEX Learning Center and is no longer being actively maintained. For the most accurate and up-to-date information, please check the official documentation.

Introduction

Performance is an increasingly critical point in the creation of a store and, to ensure that your theme is within our best optimization practices, we created this course totally focused on points of improvement in a theme.

For this course, we can use a complete theme to focus only on points for improvement.

Clone the repository: https://github.com/vtex-apps/demostore-theme


_10
git clone https://github.com/vtex-apps/demostore-theme

Fold block

Not all content on a page needs to be loaded first. Initially, when a user enters the store there is a limit on how much he can see. That is why with the __fold__ block you are able to control what will initially be seen, thus reducing the need to load data in the initial _ load _. Automatically, what is below __fold__ is, then, loaded after the essentials are already available and the user starts to _ scroll _ down.

Activity

  1. Run a vtex workspace reset ensuring that no other themes are linked in the store

  2. Go to the cloned repository directory and link and then the offered theme:


    _10
    vtex link

    You should see the following store:

    {"base64":"  ","img":{"width":3360,"height":6190,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":5109865,"url":"https://user-images.githubusercontent.com/18701182/93828834-91a87980-fc42-11ea-9f84-dd3053822621.png"}}

  3. The content below the Clearance shelf cannot be seen by the user, so let's optimize the first upload, postponing the _ fetching _ of this. To do this, in the home.jsonc file in the /store/blocks/home/ directory, add the __fold__ block just below the "shelf#clearance":


    _13
    "store.home": {
    _13
    "blocks": [
    _13
    "flex-layout.row#slider",
    _13
    "shelf#new-arrivals",
    _13
    "shelf#clearance",
    _13
    + "__fold__",
    _13
    "flex-layout.row#newsletter",
    _13
    "rich-text#brands",
    _13
    "flex-layout.row#brands",
    _13
    "rich-text#instagram",
    _13
    "flex-layout.row#instagram"
    _13
    ]
    _13
    }

In your browser, then, run a CTRL (Cmd) + - (zooming out to be able to see the whole page) and notice that everything below theClearance is loaded after (as soon as the scroll is executed) to what is above:

{"base64":"  ","img":{"width":1094,"height":1506,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":420947,"url":"https://user-images.githubusercontent.com/18701182/93830718-5fe5e180-fc47-11ea-9caf-f7b8a10b0a23.png"}}

Answer sheet

See answer sheet for home.jsonc
home.jsonc

_80
// store/blocks/home/home.jsonc
_80
{
_80
"store.home": {
_80
"blocks": [
_80
"flex-layout.row#slider",
_80
"shelf#new-arrivals",
_80
"shelf#clearance",
_80
"__fold__",
_80
"flex-layout.row#newsletter",
_80
"rich-text#brands",
_80
"flex-layout.row#brands",
_80
"rich-text#instagram",
_80
"flex-layout.row#instagram"
_80
]
_80
},
_80
_80
"carousel#home": {
_80
"props": {
_80
"autoplay": true,
_80
"autoplaySpeed": 4,
_80
"banners": [
_80
{
_80
"image": "assets/chrome1.png"
_80
}
_80
],
_80
"height": 440,
_80
"showArrows": true,
_80
"showDots": true
_80
}
_80
},
_80
_80
"flex-layout.row#slider": {
_80
"children": [
_80
// "slider-layout#styles",
_80
"carousel#home"
_80
]
_80
},
_80
_80
"flex-layout.row#brands": {
_80
"children": ["slider-layout#brands"],
_80
"props": {
_80
"marginTop": 4,
_80
"marginBottom": 8
_80
}
_80
},
_80
_80
"shelf#new-arrivals": {
_80
"blocks": ["product-summary.shelf"],
_80
"props": {
_80
"orderBy": "OrderByTopSaleDESC",
_80
"paginationDotsVisibility": "never",
_80
"collection": "139",
_80
"productList": {
_80
"maxItems": 9,
_80
"itemsPerPage": 3,
_80
"minItemsPerPage": 1.5,
_80
"scroll": "BY_PAGE",
_80
"arrows": true,
_80
"titleText": "New arrivals"
_80
}
_80
}
_80
},
_80
_80
"shelf#clearance": {
_80
"blocks": ["product-summary.shelf"],
_80
"props": {
_80
"orderBy": "OrderByTopSaleDESC",
_80
"collection": "140",
_80
"paginationDotsVisibility": "desktopOnly",
_80
"productList": {
_80
"maxItems": 9,
_80
"itemsPerPage": 3,
_80
"minItemsPerPage": 1.5,
_80
"scroll": "BY_PAGE",
_80
"arrows": true,
_80
"titleText": "Clearance"
_80
}
_80
}
_80
}
_80
}

On this page