Merge pull request #280 from towards-a-new-leftypol/defer_javascript
Defer additional_javascript for hopefully faster page loads
This commit is contained in:
commit
f6faf335fe
|
@ -59,7 +59,8 @@ var searchThreads = function($threads, query) {
|
|||
|
||||
// Only load in the catalog
|
||||
if (active_page == 'catalog') {
|
||||
onready(catalogSearch);
|
||||
|
||||
$(document).ready(catalogSearch);
|
||||
}
|
||||
|
||||
}());
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
var do_original_filename = function() {
|
||||
var filename, truncated;
|
||||
if ($(this).attr('title')) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
if (active_page == 'ukko' || active_page == 'thread' || active_page == 'index')
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
$('hr:first').before('<div id="expand-all-images" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>');
|
||||
$('div#expand-all-images a')
|
||||
.text(_('Expand all images'))
|
||||
|
|
|
@ -216,7 +216,7 @@ function setupVideosIn(element) {
|
|||
}
|
||||
}
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
// Insert menu from settings.js
|
||||
if (typeof settingsMenu != "undefined" && typeof Options == "undefined") {
|
||||
var firsthr = document.getElementsByTagName("hr")[0];
|
||||
|
|
|
@ -8,24 +8,6 @@
|
|||
*/
|
||||
function init_file_selector(max_images) {
|
||||
|
||||
$(document).ready(function () {
|
||||
// add options panel item
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
Options.extend_tab('general', '<label id="file-drag-drop"><input type="checkbox">' + _('Drag and drop file selection') + '</label>');
|
||||
|
||||
$('#file-drag-drop>input').on('click', function() {
|
||||
if ($('#file-drag-drop>input').is(':checked')) {
|
||||
localStorage.file_dragdrop = 'true';
|
||||
} else {
|
||||
localStorage.file_dragdrop = 'false';
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true';
|
||||
if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
// disabled by user, or incompatible browser.
|
||||
if (localStorage.file_dragdrop == 'false' || !(window.URL.createObjectURL && window.File))
|
||||
return;
|
||||
|
@ -190,3 +172,26 @@ $(document).on('paste', function (e) {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
// add options panel item
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
Options.extend_tab('general', '<label id="file-drag-drop"><input type="checkbox">' + _('Drag and drop file selection') + '</label>');
|
||||
|
||||
$('#file-drag-drop>input').on('click', function() {
|
||||
if ($('#file-drag-drop>input').is(':checked')) {
|
||||
localStorage.file_dragdrop = 'true';
|
||||
} else {
|
||||
localStorage.file_dragdrop = 'false';
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true';
|
||||
if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
var maxImages = document.querySelector("form[name=post]").dataset.maxImages;
|
||||
init_file_selector(Number(maxImages));
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ function updatePreviewWithSelected(img, select) {
|
|||
img.attr("src", getFlagUrl(select.find(":selected").val()));
|
||||
}
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
var flagImg = $('#flag_preview');
|
||||
var flagSelect = $('#user_flag');
|
||||
var loaded = loadFlag();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
var inline_expanding_filename = function() {
|
||||
$(this).find(".fileinfo > a").click(function(){
|
||||
var imagelink = $(this).parent().parent().find('a[target="_blank"]:first');
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function () {
|
||||
var dont_fetch_again = [];
|
||||
init_hover = function() {
|
||||
var $link = $(this);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
var showBackLinks = function() {
|
||||
var reply_id = $(this).attr('id').replace(/^reply_/, '');
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
if(device_type == 'mobile') {
|
||||
var fix_spoilers = function(where) {
|
||||
var spoilers = where.getElementsByClassName('spoiler');
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(function() {
|
||||
var stylesDiv = $('div.styles');
|
||||
var pages = $('div.pages');
|
||||
var stylesSelect = $('<select></select>').css({float:"none"});
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
|
||||
|
||||
onready(function(){
|
||||
$(document).ready(function(){
|
||||
const ON = "[Remove]";
|
||||
const OFF = "[Embed]";
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
{% if not nojavascript %}
|
||||
<script type="text/javascript" src="{{ config.url_javascript }}"></script>
|
||||
{% if not config.additional_javascript_compile %}
|
||||
{% for javascript in config.additional_javascript %}<script type="text/javascript" src="{{ config.additional_javascript_url }}{{ javascript }}"></script>{% endfor %}
|
||||
{% for javascript in config.additional_javascript %}<script defer type="text/javascript" src="{{ config.additional_javascript_url }}{{ javascript }}"></script>{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if config.recaptcha %}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
<form name="post" onsubmit="return dopost(this);" enctype="multipart/form-data" action="{{ config.post_url }}" method="post">
|
||||
<form
|
||||
name="post" onsubmit="return dopost(this);"
|
||||
enctype="multipart/form-data"
|
||||
action="{{ config.post_url }}"
|
||||
method="post"
|
||||
data-max-images="{{ config.max_images }}"
|
||||
>
|
||||
{{ antibot.html() }}
|
||||
{% if id %}<input type="hidden" name="thread" value="{{ id }}">{% endif %}
|
||||
{{ antibot.html() }}
|
||||
|
@ -142,8 +148,6 @@
|
|||
<td>
|
||||
<input type="file" name="file" id="upload_file">
|
||||
|
||||
<script type="text/javascript">if (typeof init_file_selector !== 'undefined') init_file_selector({{ config.max_images }});</script>
|
||||
|
||||
{% if config.allow_upload_by_url %}
|
||||
<div style="float:none;text-align:left" id="upload_url">
|
||||
<label for="file_url">{% trans %}Or URL{% endtrans %}</label>:
|
||||
|
|
Loading…
Reference in New Issue