Skip to content

Commit

Permalink
Merge pull request #959 from rupl/75-async
Browse files Browse the repository at this point in the history
Allow for asynchronous loading of prism.js
  • Loading branch information
zeitgeist87 committed Jun 3, 2016
2 parents b6b40ec + f130680 commit 0c4d8d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,12 @@ if (script) {
_.filename = script.src;

if (document.addEventListener && !script.hasAttribute('data-manual')) {
document.addEventListener('DOMContentLoaded', _.highlightAll);
if(document.readyState !== "loading") {
requestAnimationFrame(_.highlightAll, 0);
}
else {
document.addEventListener('DOMContentLoaded', _.highlightAll);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,12 @@ if (script) {
_.filename = script.src;

if (document.addEventListener && !script.hasAttribute('data-manual')) {
document.addEventListener('DOMContentLoaded', _.highlightAll);
if(document.readyState !== "loading") {
requestAnimationFrame(_.highlightAll, 0);
}
else {
document.addEventListener('DOMContentLoaded', _.highlightAll);
}
}
}

Expand Down

0 comments on commit 0c4d8d7

Please sign in to comment.