diff --git a/cypress/inline/embed-order.md b/cypress/inline/embed-order.md
new file mode 100644
index 000000000..ad0f6d3bf
--- /dev/null
+++ b/cypress/inline/embed-order.md
@@ -0,0 +1,11 @@
+## Embedded file order
+
+Then the content of `delayed.md` `non-delayed.md` and will be displayed directly here in correct order
+
+[delayed](_media/delayed.md ':include')
+
+---
+
+[non-delayed](_media/non-delayed.md ':include')
+
+You can check the original content for [delayed.md](_media/delayed.md ':ignore'), [non-delayed.md](_media/non-delayed.md ':ignore').
diff --git a/cypress/integration/sidebar/config.spec.js b/cypress/integration/sidebar/config.spec.js
index 4c1b511a7..7ea69fed3 100644
--- a/cypress/integration/sidebar/config.spec.js
+++ b/cypress/integration/sidebar/config.spec.js
@@ -326,6 +326,7 @@ context('sidebar.configurations', () => {
   const embedFilesIds = [
     'embedded-file-type',
     'embedded-code-fragments',
+    'embedded-file-order',
     'tag-attribute',
     'the-code-block-highlight',
   ];
@@ -336,7 +337,7 @@ context('sidebar.configurations', () => {
       cy.get(`a.section-link[href='#/embed-files?id=${id}']`)
         .click()
         .then(() => {
-          cy.wait(500);
+          cy.wait(750);
           cy.matchImageSnapshot();
         });
     });
diff --git a/cypress/live.server.js b/cypress/live.server.js
index bb22b8f07..83fd05b95 100644
--- a/cypress/live.server.js
+++ b/cypress/live.server.js
@@ -7,7 +7,16 @@ console.log('[e2e tests] : args passed to live server', args)
 const params = {
   port: args[0] || 3000,
   root: args[1] || fixturePath,
-  open: false
+  open: false,
+  middleware: [
+    function(req, res, next) {
+      if (req.url === '/_media/delayed.md') {
+        setTimeout(next, 250);
+      } else {
+        next();
+      }
+    },
+  ],
   // NoBrowser: true
-}
-LiveServer.start(params)
+};
+LiveServer.start(params)
\ No newline at end of file
diff --git a/cypress/setup.js b/cypress/setup.js
index 6372ff347..b824ed6f4 100644
--- a/cypress/setup.js
+++ b/cypress/setup.js
@@ -23,6 +23,13 @@ const setup = async () => {
   // 1
   const docsPath = path.join(process.cwd(), './docs')
   const fixtureDocsPath = path.join(__dirname, './fixtures/docs')
+  const embeddedFiles = [
+    {
+      tag: '## Tag attribute',
+      srcFile: 'embed-order.md',
+      dstFile: 'embed-files.md',
+    },
+  ];
 
   // 1.1
   console.log('[cypress test docs] Copying the docs --> cypress/fixtures/docs')
@@ -38,6 +45,21 @@ const setup = async () => {
     copyDir.sync(fromPath, toPath)
   })
 
+  // 1.3
+  embeddedFiles.forEach(({ tag, srcFile, dstFile }) => {
+    const content = fs.readFileSync(`${__dirname}/inline/${srcFile}`).toString();
+    const originalFile = `${fixtureDocsPath}/${dstFile}`;
+
+    let originalContent = fs
+      .readFileSync(originalFile)
+      .toString()
+      .split('\n');
+    const tagLine = originalContent.findIndex(l => l.indexOf(tag) >= 0);
+    originalContent.splice(tagLine, 0, content);
+
+    fs.writeFileSync(originalFile, originalContent.join('\n'));
+  });
+
   // 2
   console.log(
     '[cypress test docs] Replacing content the tpl/index.html --> cypress/fixtures/docs/index.html'
diff --git a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #configurationid=externallinkrel.snap.png b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #configurationid=externallinkrel.snap.png
index 52f1f0149..4d787bf36 100644
Binary files a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #configurationid=externallinkrel.snap.png and b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #configurationid=externallinkrel.snap.png differ
diff --git a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-code-fragments.snap.png b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-code-fragments.snap.png
index f8e05430c..d8b4bf71f 100644
Binary files a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-code-fragments.snap.png and b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-code-fragments.snap.png differ
diff --git a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-file-order.snap.png b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-file-order.snap.png
new file mode 100644
index 000000000..f791db609
Binary files /dev/null and b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-file-order.snap.png differ
diff --git a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-file-type.snap.png b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-file-type.snap.png
index 702af8421..9ac54eedf 100644
Binary files a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-file-type.snap.png and b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=embedded-file-type.snap.png differ
diff --git a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=tag-attribute.snap.png b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=tag-attribute.snap.png
index 8b4ee81a1..217ec96bd 100644
Binary files a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=tag-attribute.snap.png and b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=tag-attribute.snap.png differ
diff --git a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=the-code-block-highlight.snap.png b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=the-code-block-highlight.snap.png
index 682642579..9a88a4749 100644
Binary files a/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=the-code-block-highlight.snap.png and b/cypress/snapshots/sidebar/config.spec.js/sidebar.configurations -- go to #embed-filesid=the-code-block-highlight.snap.png differ
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index 3e9454afa..664d88d50 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -26,9 +26,8 @@
 
 import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'
 addMatchImageSnapshotCommand({
-  failureThreshold: 10.0,
+  failureThreshold: 0.10,
   failureThresholdType: 'percent',
-  customDiffConfig: { threshold: 10.0 },
   capture: 'viewport',
   timeout: '60000'
 })
diff --git a/docs/_media/delayed.md b/docs/_media/delayed.md
new file mode 100644
index 000000000..07b2be3cd
--- /dev/null
+++ b/docs/_media/delayed.md
@@ -0,0 +1,7 @@
+- This is from the `delayed.md`
+
+```bash
+sleep 1000
+echo delayed
+exit 0
+```
\ No newline at end of file
diff --git a/docs/_media/non-delayed.md b/docs/_media/non-delayed.md
new file mode 100644
index 000000000..61399c4c4
--- /dev/null
+++ b/docs/_media/non-delayed.md
@@ -0,0 +1,7 @@
+- This is from the `no-delay.md`
+
+```bash
+sleep 0 
+echo non-delayed
+exit 0
+```
\ No newline at end of file
diff --git a/src/core/render/embed.js b/src/core/render/embed.js
index 8b84c7acb..8f64e79ae 100644
--- a/src/core/render/embed.js
+++ b/src/core/render/embed.js
@@ -1,13 +1,14 @@
+import stripIndent from 'strip-indent';
 import { get } from '../fetch/ajax';
 import { merge } from '../util/core';
-import stripIndent from 'strip-indent';
 
+const INCLUDE_COMPONENT = '__include__';
 const cached = {};
 
 function walkFetchEmbed({ embedTokens, compile, fetch }, cb) {
   let token;
   let step = 0;
-  let count = 1;
+  let count = 0;
 
   if (!embedTokens.length) {
     return cb({});
@@ -72,7 +73,7 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) {
         }
 
         cb({ token, embedToken });
-        if (++count >= step) {
+        if (++count >= embedTokens.length) {
           cb({});
         }
       };
@@ -90,6 +91,23 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) {
   }
 }
 
+function expandInclude(tokens) {
+  if (!tokens) {
+    return tokens;
+  }
+
+  const expandedTokens = [];
+  tokens.forEach(e => {
+    if (e.type === INCLUDE_COMPONENT && e.components) {
+      e.components.forEach(c => expandedTokens.push(c));
+    } else {
+      expandedTokens.push(e);
+    }
+  });
+
+  return expandedTokens;
+}
+
 export function prerenderEmbed({ compiler, raw = '', fetch }, done) {
   let hit = cached[raw];
   if (hit) {
@@ -124,18 +142,19 @@ export function prerenderEmbed({ compiler, raw = '', fetch }, done) {
     }
   });
 
-  let moveIndex = 0;
   walkFetchEmbed({ compile, embedTokens, fetch }, ({ embedToken, token }) => {
     if (token) {
-      const index = token.index + moveIndex;
-
       merge(links, embedToken.links);
 
-      tokens = tokens
-        .slice(0, index)
-        .concat(embedToken, tokens.slice(index + 1));
-      moveIndex += embedToken.length - 1;
+      tokens = tokens.slice(0, token.index).concat(
+        {
+          type: INCLUDE_COMPONENT,
+          components: embedToken,
+        },
+        tokens.slice(token.index + 1)
+      );
     } else {
+      tokens = expandInclude(tokens);
       cached[raw] = tokens.concat();
       tokens.links = cached[raw].links = links;
       done(tokens);
diff --git a/src/core/render/utils.js b/src/core/render/utils.js
index 100d595cd..4bccff5b0 100644
--- a/src/core/render/utils.js
+++ b/src/core/render/utils.js
@@ -23,8 +23,8 @@ export function getAndRemoveConfig(str = '') {
 
   if (str) {
     str = str
-      .replace(/^'/, '')
-      .replace(/'$/, '')
+      .replace(/^("|')/, '')
+      .replace(/("|')$/, '')
       .replace(/(?:^|\s):([\w-]+:?)=?([\w-%]+)?/g, (m, key, value) => {
         if (key.indexOf(':') === -1) {
           config[key] = (value && value.replace(/"/g, '')) || true;