File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change
1
+ // A very simple web worker for highlight.js
2
+ // See: https://highlightjs.org/usage/
3
+ onmessage = function ( event ) {
4
+ importScripts ( '/vendor/plugins/highlight/highlight.pack.js' ) ;
5
+ var result = self . hljs . highlightAuto ( event . data ) ;
6
+ postMessage ( result . value ) ;
7
+ }
Original file line number Diff line number Diff line change @@ -1430,7 +1430,13 @@ $(document).ready(function () {
1430
1430
1431
1431
// Highlight JS
1432
1432
if ( typeof hljs != 'undefined' ) {
1433
- hljs . initHighlightingOnLoad ( ) ;
1433
+ $ ( 'pre code' ) . each ( function ( index , element ) {
1434
+ var worker = new Worker ( '/js/highlight-worker.js' ) ;
1435
+ worker . onmessage = function ( event ) {
1436
+ $ ( element ) . html ( event . data ) ;
1437
+ }
1438
+ worker . postMessage ( $ ( element ) . text ( ) ) ;
1439
+ } ) ;
1434
1440
}
1435
1441
1436
1442
// Dropzone
You can’t perform that action at this time.
0 commit comments