I am using Pug for a web page that I am building. At the end of a module I have a script.
tag (the regular script
tag cannot be used because it isn't compatible with jQuery):
script.
// load more videos
$("#btn-more").click(() => {
$.get(`#{lang}/videos?quantity=#{numVideos + 2}`)
.done((videos) => {
$(videos).ready(() => {
$("#videos").replaceWith(videos)
})
})
})
Which ends up producing code that is not minified:
<script>// load more videos
$("#btn-more").click(() => {
$.get(`en/videos?quantity=6`)
.done((videos) => {
$(videos).ready(() => {
$("#videos").replaceWith(videos)
})
})
})</script>
Is there a way to have Pug minify the code? I have not figured out how to use filters (Uglify JS) on the script.
tag.
Script: uglify-js
// load more videos
$("#btn-more").click(() => {
$.get(`#{lang}/videos?quantity=#{numVideos + 2}`)
.done((videos) => {
$(videos).ready(() => {
$("#videos").replaceWith(videos)
})
})
})
npm i jstransformer-uglify-js
:uglify-js
filter.script: :uglify-js
$("#btn-more").click(() => {
$.get(`#{lang}/videos?quantity=#{numVideos + 2}`)
.done((videos) => {
$(videos).ready(() => {
$("#videos").replaceWith(videos)
})
})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.