Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,25 +368,31 @@ This method will remove profiling information that was related to previous page
You need to inject the following in your SPA to load MiniProfiler's speed badge ([extra details surrounding this script](https://github.com/MiniProfiler/rack-mini-profiler/issues/139#issuecomment-192880706) and [credit for the script tag](https://github.com/MiniProfiler/rack-mini-profiler/issues/479#issue-782488320) to [@ivanyv](https://github.com/ivanyv)):

```html
<script type="text/javascript" id="mini-profiler"
src="/mini-profiler-resources/includes.js?v=12b4b45a3c42e6e15503d7a03810ff33"
data-css-url="/mini-profiler-resources/includes.css?v=12b4b45a3c42e6e15503d7a03810ff33"
data-version="12b4b45a3c42e6e15503d7a03810ff33"
data-path="/mini-profiler-resources/"
data-horizontal-position="left"
data-vertical-position="top"
data-ids=""
data-trivial="false"
data-children="false"
data-max-traces="20"
data-controls="false"
data-total-sql-count="false"
data-authorized="true"
data-toggle-shortcut="alt+p"
data-start-hidden="false"
data-collapse-results="true"
data-html-container="body"
data-hidden-custom-fields></script>
<script
type="text/javascript"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type attribute should be omitted here. See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your comment but its the same as in the old script in the readme file and i think if you remove it, it will create the MIME type error in the browsers.

also about the data-ids, when i leave it empty it doesnt work, how can i dynamically catch the correct id and place it in it?

id="mini-profiler"
<!-- dynamically get the backend link -->
src="<%= process.env.API_HOST %>/assets/rack-mini-profiler.js?v=116e2a6fd81c286e004e2a0afb03baa1"
data-css-url="<%= process.env.API_HOST %>/assets/rack-mini-profiler.css?v=116e2a6fd81c286e004e2a0afb03baa1"
data-version="116e2a6fd81c286e004e2a0afb03baa1"
data-path="<%= process.env.API_HOST %>/mini-profiler-resources/"
<!-- need to be fetched dynamically -->
data-ids="116e2a6fd81c286e004e2a0afb03baa1"
data-horizontal-position="left"
data-vertical-position="top"
data-trivial="false"
data-children="false"
data-max-traces="20"
data-controls="false"
data-total-sql-count="false"
data-authorized="true"
data-toggle-shortcut="alt+p"
data-start-hidden="false"
data-collapse-results="true"
data-html-container="body"
data-hidden-custom-fields
></script>

```

See an [example of how to do this in a React useEffect](https://gist.github.com/katelovescode/01cfc2b962c165193b160fd10af6c4d5).
Expand Down