You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-1
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ plugins:
61
61
2. Add a tag where the search elements should be inserted and load the search script:
62
62
```markdown
63
63
<div id="listing-extract-search"></div>
64
-
<script src="/listing-search.js">
64
+
<script src="/listing-search.js" async></script>
65
65
```
66
66
3. Specify where you want the plugin to write the script file to.
67
67
This should match the path you used in the previous step.
@@ -73,6 +73,14 @@ This should match the path you used in the previous step.
73
73
javascript_search_file: listing-search.js
74
74
```
75
75
76
+
I recommend using an absolute path for the `script.src` attribute, since it will keep working after moving the page or after switching between directory URLs and non directory URLs pages.
77
+
It just runs into problems when your base directory (where the page is deployed) is not the root directory or when you are using offline mode (from `file://` URLs).
78
+
79
+
Alternatively you can include the script and the data inline, but this can have tiny performance drawbacks:
80
+
81
+
- If you include it on multiple pages, all of them will contain a copy of the data -> reduces caching efficiency
82
+
- The whole search database needs to be downloaded while your page is loading (can not use `async` or `defer` script attributes).
logger.warning(f"Value for 'listings_file' should probably end in '.md', but is '{self.config.listings_file}'")
48
47
else:
49
48
ifnotself.config.javascript_search_file:
50
-
logger.warning("Neither 'javascript_search_file' nor 'listings_file' are set -> This plugin will do nothing. Please check the setup instructions at https://github.com/six-two/mkdocs-extract-listings-plugin/blob/main/README.md")
49
+
logger.warning("Neither 'javascript_search_file' nor 'listings_file' are set -> This plugin will do nothing, unless you use inline placeholder replacement. Please check the setup instructions at https://github.com/six-two/mkdocs-extract-listings-plugin/blob/main/README.md")
0 commit comments