Don't bundle js

HTTP/2 (supported by Netlify) offers multiplexing, so bundle/concat is not required
https://stackoverflow.com/a/36519379
Revert a4226f1413
This commit is contained in:
curben 2018-10-05 14:01:35 +09:30
parent 1e6074df9c
commit 4eca4d9ebf
2 changed files with 10 additions and 87 deletions

View File

@ -1,4 +1,8 @@
<%- js('js/main') %> <%/* javascript of Typing theme */%>
<%- js('js/typing') %>
<%/* Fallback function for SRI */%>
<%- js('js/sri-fallback.min') %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" x-sri-fallback="/js/jquery.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" x-sri-fallback="/js/jquery.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script>
@ -6,14 +10,14 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/cloudinary-jquery-file-upload/2.5.0/cloudinary-jquery-file-upload.min.js" x-sri-fallback="/js/cloudinary-jquery-file-upload.min.js" integrity="sha384-HQ/p/NgiMN4n/1y5RLzK/2SvlQeYmwEazCnpg6Vbi8dSfBcOJDvWYnvDain31AU9" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/cloudinary-jquery-file-upload/2.5.0/cloudinary-jquery-file-upload.min.js" x-sri-fallback="/js/cloudinary-jquery-file-upload.min.js" integrity="sha384-HQ/p/NgiMN4n/1y5RLzK/2SvlQeYmwEazCnpg6Vbi8dSfBcOJDvWYnvDain31AU9" crossorigin="anonymous"></script>
<script type="text/javascript">
var cl = cloudinary.Cloudinary.new({cloud_name: "curben"});
cl.responsive();
</script>
<% if (theme.fancybox){ %> <% if (theme.fancybox){ %>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.2/jquery.fancybox.min.js" x-sri-fallback="/fancybox/jquery.fancybox.min.js" integrity="sha384-j11bx3Frya+us3LfRdSq1uXZ7hsQU0UV5P3PEyRajHEHp87c8VLeM4jC/NE6SDsE" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.2/jquery.fancybox.min.js" x-sri-fallback="/fancybox/jquery.fancybox.min.js" integrity="sha384-j11bx3Frya+us3LfRdSq1uXZ7hsQU0UV5P3PEyRajHEHp87c8VLeM4jC/NE6SDsE" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.2/jquery.fancybox.min.css" x-sri-fallback="/fancybox/jquery.fancybox.min.css" integrity="sha384-GZkso4ketQR1gAuHEB2yZXtW5SF8uLAsjUsKhaHm4y33ZyPDmwnfZ8rQ4Tvqh1Et" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.4.2/jquery.fancybox.min.css" x-sri-fallback="/fancybox/jquery.fancybox.min.css" integrity="sha384-GZkso4ketQR1gAuHEB2yZXtW5SF8uLAsjUsKhaHm4y33ZyPDmwnfZ8rQ4Tvqh1Et" crossorigin="anonymous">
<% } %> <% } %>
<%/* Initialize cloudinary responsive function */%>
<script type="text/javascript">
var cl = cloudinary.Cloudinary.new({cloud_name: "curben"});
cl.responsive();
</script>

View File

@ -1,81 +0,0 @@
/* This is concat of sri-fallback.min.js and typing.js
* Any changes to typing.js needs to be reflected here (just concat again)
*/
!function(){var a="x-sri-fallback";function o(e){var r=e.getAttribute&&e.getAttribute(a),i=(e.tagName||"").toLowerCase(),n="script"===i&&e.src?"src":"link"===i&&"stylesheet"===e.rel&&e.href?"href":null;r&&n&&(e.onerror=function(){var t=document.createElement(i);t.crossOrigin=e.crossOrigin,t.integrity=e.integrity,t[n]=r,"link"===i&&(t.rel=e.rel),t.onerror=function(){console.log("SRI fallback "+r+" also failed to match integrity string "+t.integrity+".")},document.head.appendChild(t)})}new MutationObserver(function(t){for(var e=0;e<t.length;++e){for(var r=t[e],i=r.addedNodes,n=0;n<i.length;++n)o(i[n]);r.attributeName===a&&o(r.target)}}).observe(document,{childList:!0,attributes:!0,characterData:!1,subtree:!0,attributeOldValue:!1,attributeFilter:[a]})}();(function ($) {
// Fancybox caption
$('.article-entry').each(function (i) {
$(this).find('img').each(function () {
// Don't insert fancybox element to cloudinary's cld-responsive img class
if ($(this).hasClass('cld-responsive') || $(this).parent().hasClass('fancybox')) return
var alt = this.alt
if (alt) {
$(this).after('<span class="caption">' + alt + '</span>')
}
$(this).wrap('<a href="' + this.src + '" title="' + alt + '" class="fancybox"></a>')
})
$(this).find('.fancybox').each(function () {
$(this).attr('rel', 'article' + i)
})
})
if ($.fancybox) {
$('.fancybox').fancybox()
}
//Add "Copy" button to code snippet
var code = document.getElementsByClassName('code');
for (var i = 0; i < code.length; i++) {
var button = document.createElement('button');
button.className = 'copy-button';
button.textContent = 'Copy';
code[i].appendChild(button);
}
$(document).ready(function() {
// Add copy to clipboard button for code snippet
var copyCode = new ClipboardJS('.copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
}
});
copyCode.on('success', function(event) {
event.clearSelection();
event.trigger.textContent = 'Copied';
window.setTimeout(function() {
event.trigger.textContent = 'Copy';
}, 2000);
});
copyCode.on('error', function(event) {
event.trigger.textContent = 'Press "Ctrl + C" to copy';
window.setTimeout(function() {
event.trigger.textContent = 'Copy';
}, 2000);
});
// Navigation menu
$('#menu').click(function (event) {
var nav = $('#main-nav');
nav.toggle('fast');
});
// Show navigation button for smaller screen
$(window).resize(function () {
var viewportWidth = $(window).width();
if (viewportWidth > 468) {
$('#main-nav').show('fast');
} else {
$('#main-nav').hide('fast');
}
});
});
})(jQuery)