Skip to content

Commit fbf8fb2

Browse files
committed
Make runkit script async.
1 parent 098b137 commit fbf8fb2

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ vendor:
7777

7878
js:
7979
- href: https://embed.runkit.com/
80+
async: true
8081

8182
- href: https://cdn.jsdelivr.net/g/fuse@2.6.1,react@15.4.0(react.min.js+react-dom.min.js
8283
integrity: sha384-txLSiuN1HJSO1or/mE1Y6bvgD0cV3WA6Ss7rs9WqvPQ3zthR8w/DzHpB+DVTDAMz

_layouts/docs.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929
{% assign resources = resources | unshift:site.builds[page.version] %}
3030
{% for res in resources %}
3131
{% assign protocol = res.href | slice:0,6 %}
32-
{% if res.integrity and protocol == 'https:' %}
33-
<script src="{{ res.href }}" integrity="{{ res.integrity }}" crossorigin></script>
34-
{% else %}
35-
<script src="{{ res.href }}"></script>
36-
{% endif %}
32+
<script src="{{ res.href }}"{% if res.integrity and protocol == 'https:' %} integrity="{{ res.integrity }}" crossorigin{% endif %}{% if res.async %} async{% endif %}></script>
3733
{% endfor %}
3834
<script src="/assets/js/docs.js"></script>
3935
{% endcapture %}

assets/js/docs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@
425425
button.textContent = 'Try in REPL'
426426
button.style.display = navigator.onLine ? '' : 'none'
427427
button.addEventListener('click', function() {
428+
if (typeof RunKit === 'undefined') {
429+
return
430+
}
431+
428432
var source = div.innerText
429433
parent.removeChild(div)
430434
parent.removeChild(button)

0 commit comments

Comments
 (0)