Extra scripts and CSS in HEAD and footer when not logged in
Permalink Browser Info Environment
I am running 5.7.5.1. I was testing performance and noticed that in the HEAD and before the closing </body> there are a lot of unnecessary scripts and css being loaded when not in edit mode. They look necessary when adding and editing blocks, but on a live site they don't appear to do anything.
I narrowed it down to blocks created with Block Designer.
In the HEAD:
Before the closing </body>:
Anyone have insight into this and a fix? Thanks.
I narrowed it down to blocks created with Block Designer.
In the HEAD:
<link href="/updates/concrete5.7.5.1_remote_updater/concrete/css/jquery-ui.css" rel="stylesheet" type="text/css" media="all"> <link href="/updates/concrete5.7.5.1_remote_updater/concrete/css/file-manager.css" rel="stylesheet" type="text/css" media="all"> <link href="/updates/concrete5.7.5.1_remote_updater/concrete/css/select2.css" rel="stylesheet" type="text/css" media="all">
Before the closing </body>:
<script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/events.js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/bootstrap/tooltip.js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/underscore.js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/backbone.js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/jquery-ui.js"></script> <script type="text/javascript" src="http://mysite.com/ccm/assets/localization/jquery/ui/js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/select2.js"></script> <script type="text/javascript" src="http://mysite.com/ccm/assets/localization/select2/js"></script> <script type="text/javascript" src="http://mysite.com/ccm/assets/localization/core/js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/app.js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/jquery-fileupload.js"></script> <script type="text/javascript" src="/updates/concrete5.7.5.1_remote_updater/concrete/js/file-manager.js"></script>
Anyone have insight into this and a fix? Thanks.
Type: | Discussion |
---|---|
Status: | Resolved |
I've attached the controller.php and config.json from one of my simpler blocks.
It's only field is a required image. And it outputs the image URL as a background-image on a div. The view.php also includes the "Disabled in Edit Mode" message.
Starting with a blank page, there are no extraneous scripts, then after inserting the above block (or any block created with Block Designer), I get all the extra scripts I listed in my initial post.
Thanks.
It wouldn't let me attach those files, so they are here:
config.json
controller.php
It's only field is a required image. And it outputs the image URL as a background-image on a div. The view.php also includes the "Disabled in Edit Mode" message.
Starting with a blank page, there are no extraneous scripts, then after inserting the above block (or any block created with Block Designer), I get all the extra scripts I listed in my initial post.
Thanks.
It wouldn't let me attach those files, so they are here:
config.json
{"view_css":"","view_js":"","block_name":"Page Intro Image","block_description":"","block_type_set":0,"cache_block_output_lifetime":"","block_install":0,"cache_block_record":1,"cache_block_output":1,"cache_block_output_on_post":1,"cache_block_output_for_registered_users":1,"table_prefix":"","interface_width":"400","interface_height":"500","fields":{"1":{"type":"image","label":"Image","slug":"image","required":"1","prefix":"<div class=\"page-intro__image\">","suffix":"<\/div>","class":"","link":"","link_class":"","output_src_only":"1","width":"","height":"","repeatable":""}},"block_handle":"tchc_page_intro_image","packages":{"block_designer":{"version":"1.2.13"},"block_designer_pro":{"version":"1.1.5"}}}
controller.php
<?php namespace Application\Block\TchcPageIntroImage; defined("C5_EXECUTE") or die("Access Denied."); use Concrete\Core\Block\BlockController; use Core; use Loader; use \File; use Page; class Controller extends BlockController { public $helpers = array ( 0 => 'form', ); public $btFieldsRequired = array ( 0 => 'image', );
Viewing 15 lines of 76 lines. View entire code block.
OK, I see the issue. In the on_start function, it requires the file manager.
Moving this line will remove 4 .js files and 2 .css files. I will fix this in an upcoming update. If you want to fix this manually, remove this line "$this->requireAsset('core/file-manager');" and copy this after:
And
Kind regards,
Ramon
Moving this line will remove 4 .js files and 2 .css files. I will fix this in an upcoming update. If you want to fix this manually, remove this line "$this->requireAsset('core/file-manager');" and copy this after:
public function add() {
And
public function edit() {
Kind regards,
Ramon
Thanks. That fixed a couple of my blocks, but not the ones that have a repeater field.
I tried moving the three $al->register lines to the add() and edit() functions. Existing blocks still function, but can't add/edit them. The Edit modal doesn't appear.
The entire controller.php for a block with a repeater:
public function on_start() { $al = \Concrete\Core\Asset\AssetList::getInstance(); $al->register('css', 'repeatable-ft.form', 'blocks/tchc_image_video_slider/css_form/repeatable-ft.form.css', array(), $this->pkg); $al->register('javascript', 'handlebars', 'blocks/tchc_image_video_slider/js_form/handlebars-v4.0.2.js', array(), $this->pkg); $al->register('javascript', 'handlebars-helpers', 'blocks/tchc_image_video_slider/js_form/handlebars-helpers.js', array(), $this->pkg);$this->requireAsset('core/file-manager'); }
I tried moving the three $al->register lines to the add() and edit() functions. Existing blocks still function, but can't add/edit them. The Edit modal doesn't appear.
The entire controller.php for a block with a repeater:
<?php namespace Application\Block\TchcImageVideoSlider; defined("C5_EXECUTE") or die("Access Denied."); use Concrete\Core\Block\BlockController; use Core; use Loader; use \File; use Page; use URL; use \Concrete\Core\Editor\Snippet; use Sunra\PhpSimple\HtmlDomParser; use \Concrete\Core\Editor\LinkAbstractor; class Controller extends BlockController { public $helpers = array ( 0 => 'form',
Viewing 15 lines of 241 lines. View entire code block.
Nevermind. I misread the code.
was on the same line as
and it is already included in the add() and edit() functions. Just had to remove it from on_start().
Thanks again for all your help.
$this->requireAsset('core/file-manager');
was on the same line as
$al->register('javascript', 'handlebars-helpers', 'blocks/tchc_home_slider/js_form/handlebars-helpers.js', array(), $this->pkg);
and it is already included in the add() and edit() functions. Just had to remove it from on_start().
Thanks again for all your help.
So you got it all working now, or you still need help?
From what I've seen only the "File", "Image" and "Repeatable" field type have these issues (if you can call them issues haha). I will update these anytime soon! Sorry for the inconvenience so far..
Kind regards,
Ramon
From what I've seen only the "File", "Image" and "Repeatable" field type have these issues (if you can call them issues haha). I will update these anytime soon! Sorry for the inconvenience so far..
Kind regards,
Ramon
Hi there,
Version 1.3.4 should fix the problem for block you create in the future (so no more manual editing required).
Kind regards,
Ramon
Version 1.3.4 should fix the problem for block you create in the future (so no more manual editing required).
Kind regards,
Ramon
Did you also apply the fix to Block Designer Pro and the Repeatable field? I didn't see it in the version history.
Registering assets is not a biggy, the files aren't being loaded. If you are requiring assets, that's what causes to actually load it in the head and/or footer. I spotted this later, so this doesn't need fixing I assume. Or do you think otherwise? Open to any feedback/comments!
Do you have a specific example of a block that outputs extra scripts/styles? If so, post the config.json file please (or controller.php). I can take a look what could cause this.
Kind regards,
Ramon