Skip Navigation

[Resolved] A lot of unnecessary CSS and JS in HTML

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by Nigel 4 years ago.

Assisted by: Nigel.

Author
Posts
#1800137

I am trying to:
have nice views

Link to a page where the issue can be seen:
hidden link
(check source code)

I expected to see:
almost clean HTML

Instead, I got:
messy HTML

I have a lot stuff like:

<div class="toolset-blocks-styling-tmp" style="display:none;">Lndwdi12aWV3LW91dHB1dFtkYXRhLXRv ... </div>
<script class='toolset-blocks-script-tmp' type='text/javascript'>
if ( ! document.getElementById( 'toolset-blocks-styling' ) ) {
		document.head.insertAdjacentHTML(
			'beforeend',
			'<style id="' + 'toolset-blocks-styling' + '"></style>' );
}
		var style = document.getElementById( 'toolset-blocks-styling' );
		var styleTmp = document.querySelector( '.toolset-blocks-styling-tmp' );

		if( style && styleTmp ) {
			var currentStyle = style.innerHTML;
			var newStyle = window.atob( styleTmp.innerHTML );

			if( currentStyle.indexOf( newStyle ) !== -1 ) {
				// newStyle is already part of currentStyle.
				// Do Nothing.
			} else if( newStyle.indexOf( currentStyle ) !== -1 ) {
				// currentStyle is part of newStyle. Only use newStyle.
				style.innerHTML = newStyle;
			} else {
				// newStyle is not part of currentStyle, neither is currentStyle part of newStyle.
				// Keep currentStyle and append newStyle.
				style.appendChild( document.createTextNode( newStyle ) );
			}
		}

	var styleTmp = document.getElementsByClassName( 'toolset-blocks-styling-tmp' );
	while( styleTmp[0] ) {
		styleTmp[0].parentNode.removeChild( styleTmp[0] );
	}
	var scriptTmp = document.getElementsByClassName( 'toolset-blocks-script-tmp' );
	while( scriptTmp[0] ) {
		scriptTmp[0].parentNode.removeChild( scriptTmp[0] );
	}
</script>

Part with DIV is huuge (here I shortened it). This code is inserted multiple times.

#1802535

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The code is used for applying styles from blocks on the front-end, but I don't think it should be included multiple times on the same page which would be unnecessary duplication, and on the page you shared it looks like it has been added 59 times.

I checked my own test site and didn't see the same, but I'm guessing for the output of a View rather than designing the output in the View itself you are creating a Content Template and then inserting that template into the output of the View, would that be right?

When I tried the same on my test site I got a similar result.

I've escalated this to the developers, it shouldn't be happening.

I'll update you when I have any news.

#1802853

I don't need any toolset styling. I want only html structure, nothing more, no js, no css.

I have on this page Content Template which i use as some html block / section (not all page is within this template).

Views with products from woocommerce are not within this content template.

#1804771

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I discussed with the developer, who has identified a way to optimise this generally, but also identified a problem relating to the Views grid styles being inserted even when not being used, which is probably the cause of the issue you are seeing.

Both things will be addressed in this current development cycle and should be resolved in a matter of some weeks when it completes.

I'll let you know then.

#1861455

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

Today's release includes the developer changes in response to the problems you reported.

Please go ahead and update and verify the changes for yourself.

If you don't see the update in your plugins page from the custom Toolset installer page click the Check for Updates button. It is also available on the downloads page at toolset.com/account/downloads.