Optimize viz.js async rendering through webpack chunk
This commit is contained in:
parent
d3315506dc
commit
56c5378939
8 changed files with 36 additions and 35 deletions
|
@ -288,21 +288,25 @@ function finishView(view) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//graphviz
|
//graphviz
|
||||||
var graphvizs = view.find(".graphviz.raw").removeClass("raw");
|
require.ensure(["viz.js"], function(require) {
|
||||||
graphvizs.each(function (key, value) {
|
var Viz = require("viz.js");
|
||||||
try {
|
var graphvizs = view.find(".graphviz.raw").removeClass("raw");
|
||||||
var $value = $(value);
|
graphvizs.each(function (key, value) {
|
||||||
var $ele = $(value).parent().parent();
|
try {
|
||||||
|
var $value = $(value);
|
||||||
|
var $ele = $(value).parent().parent();
|
||||||
|
|
||||||
var graphviz = Viz($value.text());
|
var graphviz = Viz($value.text());
|
||||||
$value.html(graphviz);
|
$value.html(graphviz);
|
||||||
|
|
||||||
$ele.addClass('graphviz');
|
$ele.addClass('graphviz');
|
||||||
$value.children().unwrap().unwrap();
|
$value.children().unwrap().unwrap();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
})
|
||||||
//mermaid
|
//mermaid
|
||||||
var mermaids = view.find(".mermaid.raw").removeClass("raw");
|
var mermaids = view.find(".mermaid.raw").removeClass("raw");
|
||||||
mermaids.each(function (key, value) {
|
mermaids.each(function (key, value) {
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
/* include jquery ui */
|
|
||||||
require('jquery-ui/ui/widgets/resizable');
|
|
||||||
require('jquery-ui/ui/widgets/tooltip');
|
|
||||||
require('jquery-ui/ui/widgets/controlgroup');
|
|
||||||
require('jquery-ui/ui/widgets/autocomplete');
|
|
||||||
|
|
||||||
/* jquery and jquery plugins */
|
/* jquery and jquery plugins */
|
||||||
require('../vendor/showup/showup');
|
require('../vendor/showup/showup');
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<script src="<%- url %>/vendor/mermaid/dist/mermaid.min.js" defer></script>
|
<script src="<%- url %>/vendor/mermaid/dist/mermaid.min.js" defer></script>
|
||||||
<% } %>
|
<% } %>
|
||||||
<script src="<%- url %>/vendor/Idle.Js/build/idle.min.js" defer></script>
|
<script src="<%- url %>/vendor/Idle.Js/build/idle.min.js" defer></script>
|
||||||
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
|
<script src="<%- url %>/build/vendor.js" defer></script>
|
||||||
<!--codemirror-->
|
<!--codemirror-->
|
||||||
<script src="<%- url %>/vendor/codemirror/codemirror.min.js" defer></script>
|
<script src="<%- url %>/vendor/codemirror/codemirror.min.js" defer></script>
|
||||||
<script src="<%- url %>/vendor/inlineAttachment/inline-attachment.js" defer></script>
|
<script src="<%- url %>/vendor/inlineAttachment/inline-attachment.js" defer></script>
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
<!-- Bootstrap core JavaScript
|
<!-- Bootstrap core JavaScript
|
||||||
================================================== -->
|
================================================== -->
|
||||||
<!-- Placed at the end of the document so the pages load faster -->
|
<!-- Placed at the end of the document so the pages load faster -->
|
||||||
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
|
<script src="<%- url %>/build/vendor.js" defer></script>
|
||||||
<% if(useCDN) { %>
|
<% if(useCDN) { %>
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js" defer></script>
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js" defer></script>
|
||||||
<script src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js" defer></script>
|
<script src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js" defer></script>
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js" defer></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js" defer></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
|
<script src="<%- url %>/build/vendor.js" defer></script>
|
||||||
<script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script>
|
<script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script>
|
||||||
<script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script>
|
<script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script>
|
||||||
<script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script>
|
<script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script>
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js" defer></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js" defer></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<script src="<%- url %>/build/vendor.bundle.js" defer></script>
|
<script src="<%- url %>/build/vendor.js" defer></script>
|
||||||
<script src="<%- url %>/vendor/reveal.js/lib/js/head.min.js"></script>
|
<script src="<%- url %>/vendor/reveal.js/lib/js/head.min.js"></script>
|
||||||
<script src="<%- url %>/vendor/reveal.js/js/reveal.js"></script>
|
<script src="<%- url %>/vendor/reveal.js/js/reveal.js"></script>
|
||||||
<script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script>
|
<script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script>
|
||||||
|
|
|
@ -17,10 +17,11 @@ module.exports = Object.assign({}, baseConfig, {
|
||||||
}),
|
}),
|
||||||
new ExtractTextPlugin("[name].css"),
|
new ExtractTextPlugin("[name].css"),
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
name: "vendor",
|
name: ["vendor", "public", "slide", "locale"],
|
||||||
filename: "vendor.bundle.js",
|
async: true,
|
||||||
minChunks: Infinity,
|
filename: '[name].js',
|
||||||
}),
|
minChunks: Infinity
|
||||||
|
})
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
'NODE_ENV': JSON.stringify('production')
|
'NODE_ENV': JSON.stringify('production')
|
||||||
|
|
|
@ -17,9 +17,10 @@ module.exports = {
|
||||||
}),
|
}),
|
||||||
new ExtractTextPlugin("[name].css"),
|
new ExtractTextPlugin("[name].css"),
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
name: "vendor",
|
name: ["vendor", "public", "slide", "locale"],
|
||||||
filename: "vendor.bundle.js",
|
async: true,
|
||||||
minChunks: Infinity,
|
filename: '[name].js',
|
||||||
|
minChunks: Infinity
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -33,9 +34,12 @@ module.exports = {
|
||||||
"jquery-textcomplete",
|
"jquery-textcomplete",
|
||||||
"jquery-mousewheel",
|
"jquery-mousewheel",
|
||||||
"jquery-scrollspy/jquery-scrollspy",
|
"jquery-scrollspy/jquery-scrollspy",
|
||||||
|
"jquery-ui/ui/widgets/resizable",
|
||||||
|
"jquery-ui/ui/widgets/tooltip",
|
||||||
|
"jquery-ui/ui/widgets/controlgroup",
|
||||||
|
"jquery-ui/ui/widgets/autocomplete",
|
||||||
"expose?LZString!lz-string",
|
"expose?LZString!lz-string",
|
||||||
"expose?filterXSS!xss",
|
"expose?filterXSS!xss",
|
||||||
"expose?Viz!viz.js",
|
|
||||||
"js-url",
|
"js-url",
|
||||||
"bootstrap"
|
"bootstrap"
|
||||||
]
|
]
|
||||||
|
@ -43,6 +47,7 @@ module.exports = {
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'public/build'),
|
path: path.join(__dirname, 'public/build'),
|
||||||
|
publicPath: '/build/',
|
||||||
filename: '[name].js'
|
filename: '[name].js'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -51,10 +56,7 @@ module.exports = {
|
||||||
path.resolve(__dirname, 'src'),
|
path.resolve(__dirname, 'src'),
|
||||||
path.resolve(__dirname, 'node_modules')
|
path.resolve(__dirname, 'node_modules')
|
||||||
],
|
],
|
||||||
extensions: ["", ".js"],
|
extensions: ["", ".js"]
|
||||||
alias: {
|
|
||||||
'jquery-ui': 'jquery-ui/ui/widgets'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
|
|
Loading…
Reference in a new issue