mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 23:00:28 -04:00
Initialise highlighting without jQuery
Nothing against the venerable old library, but it’s only being used here as a loader for the syntax highlighter. This approach will work in everything even remotely modern (IE9+, everything else), and saves 30Kb gzipped plus parsing time on the pages it’s used on.
This commit is contained in:
parent
cb47dc102e
commit
2affd08cf9
3 changed files with 5 additions and 7 deletions
|
@ -35,7 +35,6 @@ if(!isset($js)){
|
||||||
<meta content="#394451" name="theme-color">
|
<meta content="#394451" name="theme-color">
|
||||||
<? if($js){ ?>
|
<? if($js){ ?>
|
||||||
<link href="/js/highlight.js/styles/paraiso-dark.css" rel="stylesheet">
|
<link href="/js/highlight.js/styles/paraiso-dark.css" rel="stylesheet">
|
||||||
<script src="/js/jquery-3.3.1.min.js"></script>
|
|
||||||
<script src="/js/highlight.js/highlight.pack.js"></script>
|
<script src="/js/highlight.js/highlight.pack.js"></script>
|
||||||
<script src="/js/core.js"></script>
|
<script src="/js/core.js"></script>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$(function(){
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
if(hljs){
|
if(hljs){
|
||||||
$('code.html.full, code.css.full, figure code.html').each(function(i, block) {
|
var blocks = document.querySelectorAll('code.html.full, code.css.full, figure code.html');
|
||||||
hljs.highlightBlock(block);
|
for (var i=0; i<blocks.length; i++) {
|
||||||
});
|
hljs.highlightBlock(blocks[i]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
2
www/js/jquery-3.3.1.min.js
vendored
2
www/js/jquery-3.3.1.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue