{"id":4836,"date":"2026-10-27T10:40:58","date_gmt":"2026-10-27T08:40:58","guid":{"rendered":"https:\/\/fastpixel.io\/?post_type=docs&#038;p=4836"},"modified":"2026-10-27T10:41:01","modified_gmt":"2026-10-27T08:41:01","password":"","slug":"fastpixel-dynamic-fragments-how-to-guide","status":"publish","type":"docs","link":"https:\/\/fastpixel.io\/fr\/docs\/fastpixel-dynamic-fragments-how-to-guide\/","title":{"rendered":"FastPixel Dynamic Fragments: How-To Guide"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Fragments let you keep most of a page cached and optimized while refreshing&nbsp;selected dynamic sections, such as a rotating testimonial or a changing public&nbsp;announcement. Dynamic fragments are included in the FastPixel plugin; no&nbsp;separate installation is needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Mark the section to refresh<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Page-content fragments<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Add an HTML comment immediately before and after the dynamic section:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- fp-fragment:customer_testimonial:start --&gt;\n&lt;!-- Your existing dynamic content stays here, unchanged. --&gt;\n&lt;!-- fp-fragment:customer_testimonial:end --&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace&nbsp;<code>customer_testimonial<\/code>&nbsp;with your fragment&#8217;s name. Keep your existing&nbsp;content, shortcode, or supported widget between the comments. The comments mark&nbsp;what to refresh; they do not make static text dynamic by themselves.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Do not add an extra&nbsp;<code>&lt;div&gt;<\/code>&nbsp;or other wrapper.<\/strong>&nbsp;Only add the opening and&nbsp;closing comments around the existing content. A fragment can contain one or&nbsp;several top-level elements; FastPixel applies the fade to those elements&nbsp;individually, together, without inserting a wrapper.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use an HTML-capable editor block or your page&#8217;s HTML editing mode. The markers&nbsp;must appear as actual HTML comments in the rendered page, not visible text or&nbsp;an escaped code example. Visitors will not see the comments.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Follow these rules:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use exactly the same name in the opening and closing comments.<\/li>\n\n\n\n<li>Choose a name of 1-64 letters (<code>a-z<\/code>, <code>A-Z<\/code>), digits, underscores, or hyphens, such as <code>daily_offer<\/code>. Do not use spaces.<\/li>\n\n\n\n<li>Give each page-content fragment on a page a unique name.<\/li>\n\n\n\n<li>Both comments must share the same existing HTML parent. Do not put one inside a section and the other outside it; no new container is needed.<\/li>\n\n\n\n<li>Do not nest fragments inside other fragments.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Not every page builder or widget is supported, particularly content outside&nbsp;the page body, such as template headers and footers. Ask your site administrator&nbsp;to confirm compatibility if needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Save the page and refresh its FastPixel cache so the optimized version includes&nbsp;your markers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Custom HTML widget fragments<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For content in a standard WordPress&nbsp;<strong>Custom HTML widget<\/strong>, use the separate&nbsp;widget markers inside that widget&#8217;s saved content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- fp-fragment-widget:testies_main:start -->\n&#91;ggshortcode_testies]\n&lt;!-- fp-fragment-widget:testies_main:end --><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&nbsp;<code>testies_main<\/code>&nbsp;is a fragment name you choose,&nbsp;<strong>not<\/strong>&nbsp;the widget title or&nbsp;the name of its widget area (such as &#8220;Home page&#8221;). Assign the widget to a&nbsp;registered, active widget area. The integration discovers which widget contains&nbsp;the markers; you do not need to add its internal ID or sidebar name. Moving it&nbsp;to another registered area does not require changing the markers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Shortcodes work only if your site already enables them in Custom HTML widgets&nbsp;through their normal content filters. The integration does not add shortcode&nbsp;execution. Test that the unoptimized widget already renders correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Widget fragment names must be unique across all eligible Custom HTML widgets&nbsp;on the site. A widget may contain several separate fragments. A page-content&nbsp;fragment and a widget fragment may use the same name, but fragments of either&nbsp;type must not be nested inside one another. Each widget fragment may appear&nbsp;only once on a rendered page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Public-access opt-in:<\/strong>&nbsp;adding these markers makes that fragment available&nbsp;through the public widget endpoint while the widget is assigned to an eligible&nbsp;area. Do not mark private\/member-only content or rely on the original page&#8217;s&nbsp;access controls or sidebar visibility rules to protect it. Inactive, unassigned,&nbsp;and unregistered-area widgets are not served.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This route renders only the selected widget, not the page or entire sidebar.&nbsp;It works on a blog\/posts-index page too. Widgets that depend on the original&nbsp;page&#8217;s query, current post, or theme-template setup are not supported by this&nbsp;isolated rendering mechanism. Block widgets and arbitrary third-party widget&nbsp;types are not automatically supported.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The widget markers support the same fade-in,&nbsp;<code>:clipping<\/code>, and status behavior&nbsp;described below. Refresh affected FastPixel page caches after adding\/changing&nbsp;markers or moving\/removing a widget.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Choose how fresh content appears<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Default: fade in<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The example above uses fade-in automatically. You can also request it explicitly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- fp-fragment:customer_testimonial:start:fadein --&gt;\n&lt;!-- Your existing dynamic content stays here, unchanged. --&gt;\n&lt;!-- fp-fragment:customer_testimonial:end --&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When refreshing starts, FastPixel temporarily hides the cached section while&nbsp;keeping its layout space. Fresh content fades in over&nbsp;<strong>350 milliseconds<\/strong>.&nbsp;If the refresh fails or takes longer than&nbsp;<strong>5 seconds<\/strong>, the cached content&nbsp;is shown again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The cached section may briefly appear before refreshing starts. Visitors who&nbsp;prefer reduced motion do not get the fade. The effect is also skipped when it&nbsp;would conflict with existing animations, styles, or unwrapped text.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, if the section already contains two sibling paragraphs, both&nbsp;fade together without a surrounding&nbsp;<code>&lt;div&gt;<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- fp-fragment:customer_testimonial:start --&gt;\n&lt;p&gt;Existing testimonial text.&lt;\/p&gt;\n&lt;p&gt;Existing customer name.&lt;\/p&gt;\n&lt;!-- fp-fragment:customer_testimonial:end --&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Text directly between the markers but outside any element is still refreshed,&nbsp;but causes the fade effect to be skipped. Whitespace between elements is fine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">No fade: clipping<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Add&nbsp;<code>:clipping<\/code>&nbsp;to the&nbsp;<strong>opening comment only<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- fp-fragment:customer_testimonial:start:clipping --&gt;\n&lt;!-- Your existing dynamic content stays here, unchanged. --&gt;\n&lt;!-- fp-fragment:customer_testimonial:end --&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This keeps the cached section visible while fresh content is requested, then&nbsp;replaces it without a fade. Despite its name, this option does not crop content.&nbsp;It does not use the default mode&#8217;s five-second timeout; cached content remains&nbsp;visible while waiting, or if the request fails.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use clipping when keeping content visible matters more than temporarily showing&nbsp;an older version. Neither mode prevents layout shifts if the replacement has&nbsp;different dimensions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. How it works<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>FastPixel serves the optimized page with a cached copy of the fragment.<\/li>\n\n\n\n<li>The visitor&#8217;s browser automatically requests fresh content from your WordPress site, without waiting for a click or scroll.<\/li>\n\n\n\n<li>Only the marked section is replaced. The rest of the page stays in place.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Each fragment refreshes independently, once per page load. This is not continuous&nbsp;live updating. If JavaScript is disabled, the cached content stays visible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You do not need to enter an API URL: FastPixel uses the site&#8217;s advertised&nbsp;WordPress REST address, including supported subdirectory installations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tips and checking your setup<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Mark only sections that need fresh content. Each fragment adds a request to your site; the main page can appear before dynamic content is ready.<\/li>\n\n\n\n<li>Keep replacement sizes reasonably consistent to reduce visible movement.<\/li>\n\n\n\n<li>Use public content suitable for caching as a fallback, not private account details or content that must never display an older value.<\/li>\n\n\n\n<li>Fragments refresh HTML and supported CSS, not JavaScript-driven widget initialization. Embedded scripts or separate asset tags in the returned content are not supported.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Open the optimized page and confirm the section refreshes. A fresh result may&nbsp;look identical if the underlying content has not changed. For a technical&nbsp;check, inspect the live page&#8217;s comments:&nbsp;<code>fallback<\/code>&nbsp;changes to&nbsp;<code>dynamic<\/code>&nbsp;after&nbsp;a successful replacement. FastPixel adds these labels; do not add them yourself.&nbsp;The saved page source still shows the cached fallback.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If it does not refresh, check the marker rules and ask your administrator to&nbsp;check compatibility and browser console errors.<\/p>","protected":false},"excerpt":{"rendered":"<p>Fragments let you keep most of a page cached and optimized while refreshing&nbsp;selected dynamic sections, such as a rotating testimonial or a changing public&nbsp;announcement. Dynamic fragments are included in the FastPixel plugin; no&nbsp;separate installation is needed. 1. Mark the section to refresh Page-content fragments Add an HTML comment immediately before and after the dynamic section: [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","footnotes":""},"doc_category":[13],"doc_tag":[],"class_list":["post-4836","docs","type-docs","status-publish","hentry","doc_category-fastpixel-website-accelerator"],"blocksy_meta":[],"year_month":"2026-10","word_count":1277,"total_views":"8","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Adrian","author_nicename":"adrian","author_url":"https:\/\/fastpixel.io\/fr\/blog\/author\/adrian\/"},"doc_category_info":[{"term_name":"FastPixel Website Accelerator","term_url":"https:\/\/fastpixel.io\/fr\/docs-category\/fastpixel-website-accelerator\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"trp-custom-language-flag":false,"betterdocs-category-thumb":false},"uagb_author_info":{"display_name":"Adrian","author_link":"https:\/\/fastpixel.io\/fr\/blog\/author\/adrian\/"},"uagb_comment_info":0,"uagb_excerpt":"Fragments let you keep most of a page cached and optimized while refreshing&nbsp;selected dynamic sections, such as a rotating testimonial or a changing public&nbsp;announcement. Dynamic fragments are included in the FastPixel plugin; no&nbsp;separate installation is needed. 1. Mark the section to refresh Page-content fragments Add an HTML comment immediately before and after the dynamic section:\u2026","_links":{"self":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/comments?post=4836"}],"version-history":[{"count":1,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4836\/revisions"}],"predecessor-version":[{"id":4837,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/docs\/4836\/revisions\/4837"}],"wp:attachment":[{"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/media?parent=4836"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/doc_category?post=4836"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/fastpixel.io\/fr\/wp-json\/wp\/v2\/doc_tag?post=4836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}