Scripts being duplicated on save

Thanks for reporting an issue! Spend 60 seconds reading this…

  1. Before reporting, make sure you have the latest version of Wappler.
  2. Make sure you have searched the forum first for similar issues being reported
  3. If it is a general web related issue - do a Google Search first
  4. Issue tracker is only for bugs and feature requests, in English only.
  5. Learn how to report bugs effectively

======== TEMPLATE BUG FORM ========

Wappler Version :
Operating System :

Expected behavior

What do you think should happen?

Save should not add duplicates

Actual behavior

What actually happens?

JS scripts duplicated

Restart seemed to stop most scripts being added although following still auto added

	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

	<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

See video, I assume any bug reports will have been self reported but have added one anyway (only covers the post restart additions)

addbug.mp4 (15.8 MB)

chrome_debug.zip (56.8 KB)

Just in case it is any help, i had just added the following to all pages in the site by pasting the code, before this scripts were not duplicated.

	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="canonical" href="https://woodpelletstoves.co.uk">

I also noted that the canonical tag was being auto changed to be contained in a div like this.

	<div id="">
		<link rel="canonical" href="https://woodpelletstoves.co.uk">
	</div>

The duplicate scripts are caused by the div in the head section, adding a div in the head it will break and put all content after the div in the body, it then doesn’t find the includes in the head and reinserts them.

When was the canonical link being changed? Was this after you pasted it in the document or when you saved the document.

I didn’t add the div to the head, wappler did that at the same time as adding the duplicate scripts. The scripts and div were added on save i believe

However I think i have identified the cause.

The canonical link is missing a closing fore-slash

I had the link set as

<link rel="canonical" href="https://woodpelletstoves.co.uk">

where is should be

<link rel="canonical" href="https://woodpelletstoves.co.uk"/>

This sees to be confusing Wappler and causing the issue as i have corrected them and all is well

The link tag doesn’t need the slash, that is only needed for xhtml pages. Also that would also not cause the div being added. The duplicated scripts are caused by the div in the header, so it must have been added before it was being duplicated.

We will improve the detection of the scripts in Wappler, so that scripts don’t get duplicated when they are outside of the head. Any invalid tag in the the head (or text nodes) will move the content after that to the body, this is the default behavior for html. You can see this behavior when you inspect the page with devtools in the browser, you will notice the elements are moved to the body.

Definitely no other divs in the header patrick. This problem started when i pasted in the above code via the code windows,

The problem could be stopped by removing the code or alternatively adding the fore-slash also appeared to stop it happening